Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to connect to MySQL

Status
Not open for further replies.

ShamaJamms

Programmer
Mar 28, 2007
11
HTTP, PHP, and MySQL servers are all running localhost on my machine, and configured/setup. I am able to login and edit MySQL via Windows command prompt. But when I issue a PHP connect command and run the PHP page on my browser, I'm unable to connect. All other PHP scripts work fine.
Here is my code:


<?php
mysql_connect("localhost", "root", "mypassword") or die(mysql_error());
echo "Connected to MySQL";
?>

 
What error does it give?

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
No error. Just a blank, white page. After I View>Source, I see no code, either.
 
edit php.ini (find out which one by running phpinfo()).

make sure that display_startup_errors and display_errors are set to on. and that error_reporting is set to E_ALL.

then restart the webserver and rerun your script and report back the error you receive.

please also read sleipnir214's FAQ on debugging in the FAQ section of this forum
 
I believe I've got it working, thank you.

I turned on startup errors in PHP.ini, and found out that I was missing php_mysql.dll. After a quick Google search, I downloaded it, put it in my PHP folder, restarted Apache, and ran the mysql_connect page again, and it said "Connected to MySQL."

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top