myrddinwylt Posted July 9, 2010 Share Posted July 9, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207202-mysql_connect-connection-attempt-failed/ Share on other sites More sharing options...
myrddinwylt Posted July 10, 2010 Author Share Posted July 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207202-mysql_connect-connection-attempt-failed/#findComment-1084136 Share on other sites More sharing options...
PFMaBiSmAd Posted July 10, 2010 Share Posted July 10, 2010 The 'localhost' keyword works in php 5.3.x just fine. Php 5.3 does not use "libmysql.dll" as the client library by default. It contains a built in native driver. Quote Link to comment https://forums.phpfreaks.com/topic/207202-mysql_connect-connection-attempt-failed/#findComment-1084139 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.