vladqui Posted January 17, 2011 Share Posted January 17, 2011 Hello I have been working with php and mysql for some time, but today I am totally blocked with this new problem. I installed Apache 2.2.11, MySQL 5.0.45 with MySQL Client 5.1.11 and PHP 5.3.3. All of this on a PC running Windows Server 2008 I also installed a couple of MySQL GUI´s and uploaded the Database. Apache is working OK, it restarts with no problem MySQL seems to be working OK and I can edit the tables PHP appears to be OK and I get the phpInfo screen where strangely there is no Active Link. When I try to connect to the database, the system stalls until I get the message: Fatal error: Maximum execution time of 30 seconds exceeded in ... There is no error messge and the server error log is empty, since PHP has never connected to the DB. All the corresponding extentions are habilitated in php.ini and the extentions directory is correct in httpd.conf. At this moment I am out of ideas.... PLEASE help. Regards, Vladimir Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/ Share on other sites More sharing options...
requinix Posted January 17, 2011 Share Posted January 17, 2011 What's your code and where (according to the error message) does it time out? Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161076 Share on other sites More sharing options...
vladqui Posted January 18, 2011 Author Share Posted January 18, 2011 Hi It is the simplest code, just to test: $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); Nothing happens until the Maximum execution time warning appears. No other error, Nothing... Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161080 Share on other sites More sharing options...
requinix Posted January 18, 2011 Share Posted January 18, 2011 And MySQL is running? On localhost? On port 3306? Open up a command prompt (Start > Run "cmd.exe") and type telnet localhost 3306 If the screen doesn't clear and you don't see a bunch of weird characters then MySQL is not running where PHP is expecting to find it. Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161099 Share on other sites More sharing options...
vladqui Posted January 18, 2011 Author Share Posted January 18, 2011 Yes, Mysql is running on port 3306. I have revised it with MysqlGuiTools and Workbench. I even dumped the database and it works OK. But PHP does not seem to recognize it in odred to make the connection. VQ Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161327 Share on other sites More sharing options...
requinix Posted January 18, 2011 Share Posted January 18, 2011 And you posted the entirety of your code? There is nothing else? I mean literally: copy/paste everything into a post. Also, which line number does the error say the timeout happened on? Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161347 Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 I'm not certain where I saw it, but I seem to remember someone having the same problem resolved it by using the IP addresss rather than the hostname. It's worth a shot at least. Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1161351 Share on other sites More sharing options...
vladqui Posted January 19, 2011 Author Share Posted January 19, 2011 Thanks Pikachu That was the idea I needed...! I forgot to mention I am working this installation on a Intranet, maybe that is why the server name is not properly translated into its IP. So PHP did not know where to look for the DB server. I simply replaced every instance of 'localhost' by '127.0.0.1' on each configuration file and.... VOILA magically everything started to work as expected. This small piece of information saved me many more hours of frustration. Happy New Year...! VQ Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1162183 Share on other sites More sharing options...
Pikachu2000 Posted January 19, 2011 Share Posted January 19, 2011 Excellent. Glad that fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/224771-php-cannot-conect-to-mysql/#findComment-1162189 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.