wood burning stoves 2.0*
The moose likes PHP and the fly likes problem php with mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "problem php with mysql" Watch "problem php with mysql" New topic
Author

problem php with mysql

Zac Vincent
Greenhorn

Joined: Nov 14, 2012
Posts: 5
Hi, I am new here and I do not know where to put my questions and problems regarding php and mysql. I recently installed php 5 and mysql 5.5 and apache web server individually on my windows 7 operating system. I also intalled netbean ide. So far without database, my php file will work. For example <?php echo phpinfo(); ?> will work. But when I try to connect my php file with the database , it fails. In my netbean ide, I tried to test connection but it fails and shows the following errors......

Cannot establish a connection to jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=convertToNull using com.mysql.jdbc.Driver (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)


My server host name is localhost.
server port number is 3306
username is root
and password ="".

Could anyone identify the problems I am having? I do understand there is an easy way of installing WAMP using XAMPP. But I want to try to do the another way. Another question .... Should mysql be installed inside the web server or outside or as separate location?

Thanks in advance.

Zac
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

Is mysql running? Can you connect to mysql usinf the command line mysql tool?
Zac Vincent
Greenhorn

Joined: Nov 14, 2012
Posts: 5
Yes it is running. I can see my databases there. I usually see it in the mysql command line console.

Thank you.
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

Then I'm stumped as to why NetBeans cannot communicate with MySQL. Accodring to you, all of the conditions have been met: MySQL is urnning on the same maching as NetBeasn and opened port 3306, and I assume you used hte correct username and password. And since it is localhost there are no firewall issues (that happens only for remote servers). How confortable are you with Java? Could you write a simple Java app to connect to the database, and if so, does that work.

Let's look at the PHP code instead - could you post the code you use to access MySQL.
Zac Vincent
Greenhorn

Joined: Nov 14, 2012
Posts: 5
here is my script for database connection.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem php with mysql
 
Similar Threads
Connect realphone J2ME program to PC localhost database vie TCP connection.
connection with database
Communication with wampserver and netbeans 7.0.1
NOt able to connect to actual database on the web server
Using PHP with MySql