Jump to content

Recommended Posts

Hello,

 

Kind of a bizzare problem. From within PHP 5.3.2, if i try

 

mysql_connect("localhost","root","") or die(mysql_error());

 

It results in the following message:

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23

Fatal error: Maximum execution time of 30 seconds exceeded in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23

 

If I try to connect on the same machine, but instead of using PHP, I use the command prompt (or quite literally connect in any other way except PHP), I connect with no problems:

 

C:\server\bin>mysql -P 3306 -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.1.30-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye

 

The "libmysql.dll" located in the PHP folder, is the same version for the server. What else am I missing ?  This only became a problem after updating (with a lot of effort), to PHP 5.3.2.  I kind of need to connect to MySQL using PHP

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/207202-mysql_connect-connection-attempt-failed/
Share on other sites

Figured out the problem

 

Apparently PHP 5.3.2 isn't smart enough to resolve "localhost" as "127.0.0.1" ... I put the IP in, and it works.  I tested this on an older version of PHP on the same machine, and the flaw was not present before 5.3.x.

 

 

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.