This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

problem php with mysql

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 71
PHP Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is mysql running? Can you connect to mysql usinf the command line mysql tool?
 
Zac Vincent
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
PHP Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my script for database connection.


 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic