Alternamaton Posted June 3, 2007 Share Posted June 3, 2007 When I try to run this script, the bar at the bottom of my browser says "Waiting for localhost..." but nothing happens. Here's the script that I'm trying to use to connect to MySQL: <html> <body> <?php $con = mysql_connect("localhost:8080","root@localhost","***********"); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> </body> </html> Obviously I didn't really enter *********** for my password; I entered my password. If I take out the :8080, I get the following error message: Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Web\Webserver\Apache2\htdocs\mysqlconnect.php on line 4 Could not connect: Can't connect to MySQL server on 'localhost' (10061). I've tried running the script with and without MySQL running in the console. I've also tried using the username that I set, but I changed it when I queried MySQL and got the username that I was apparently logged in under. I'm on Windows XP home edition, and I know that I have PHP and Apache installed correctly, because they work together. I have the mysql and mysqli extensions enabled in my php.ini file (though I don't really need mysqli enabled, since I'm not using MySQL Improved, right?). I did a search of the forums, but I didn't find anyone else on Windows who's just getting a page that won't load when they try to connect to MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/54057-cant-connect-to-mysql-with-a-php-script-i-dont-even-get-an-error-message/ Share on other sites More sharing options...
Alternamaton Posted June 3, 2007 Author Share Posted June 3, 2007 Update: After trying to open the page for a while, the following error message is displayed: Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in C:\Web\Webserver\Apache2\htdocs\mysqlconnect.php on line 4 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Web\Webserver\Apache2\htdocs\mysqlconnect.php on line 4 Quote Link to comment https://forums.phpfreaks.com/topic/54057-cant-connect-to-mysql-with-a-php-script-i-dont-even-get-an-error-message/#findComment-267255 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.