PHP - MySQL link not working

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
varunj
Forum Newbie
Posts: 1
Joined: Sat Jul 24, 2010 4:41 am

PHP - MySQL link not working

Post by varunj »

Hi all,
Just trying to setup the Apache, PHP, MySQL trio on my computer for the first time, and seem to be facing a problem many people have - the connection between PHP and MySQL.

I have got Apache (2.2), PHP (5.3.3) and MySQL (5.1) to work independently.

However, when I try to use a test file (mysql_test.php placed in the htdocs folder) to test the connection between PHP and MySQL I get the following error:

--
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:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 9

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:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 9

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 9
--

I have tried everything I could find:

1. I have removed the semicolon before extension=php_mysql.dll and extension=php_mysqli.dll
2. I have changed the line and removed the semicolon before extension_dir = "C:\php\ext"
3. I have added the file libmySQL.dll file to C:\Windows
4. I have added C:\php to the Windows Path system variable
5. Restarted the computer
6. Restarted the Apache server

I have attached my php.ini and mysql_test.php files to this message.

Really don't know what else to do. If you need any more info, let me know.

Thanks
Attachments
mysql_test.zip
(423 Bytes) Downloaded 149 times
php.zip
(20.53 KiB) Downloaded 122 times
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: PHP - MySQL link not working

Post by liljester »

what version of windows? ive had issues with getting php to see mysql on server 2008r2 because localhost automatically maps to the IPv6 address, that mysql isnt listening on. the fix i came up with was to edit c:\windows\system32\drivers\etc\host file, at the bottom add "127.0.0.1 localhost". this tells windows to map localhost to the IPv4 address.
Post Reply