Jump to content

Can't connect to MySQL with a PHP script--I don't even get an error message.


Alternamaton

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.