I've recently installed Apache version 2.2, MySql version 5.1, and PHP version 5.2.13 and am using Windows as my OS. I've gotten PHP to work on the Apache server, and MySql is working properly on its own. However, when I try to connect to a mysql database, I get this error:

fatal error: "undefined function mysql_connect()"

I've read literally 20 to 30 tech forums about this error. It appears to be a common problem with php versions 5 + because mysql extensions are no longer bundled with php. However, I've tried every fix imaginable and still nothing. Fixes I've tried include:

1. removing the semicolon from the php_mysql extension in the php.ini file
2. adding both c:\php and c:\php\ext\ to my PATH directory (php is my main directory)
3. ensuring that my libmysql.dll is located in the same folder as my php.exe file
4. ensuring that the php_mysql extension is available in my c:\php\ext folder

Despite all of these steps (and many more), I've still had no success. Can someone please help me, I'm about to give up on PHP because of this problem...

8 Years
Discussion Span
Last Post by Justin81

Plz restart your WAMP server(PHP+Mysql+Apache)
if ur using windows
and If u r using Linux.. restart LAMP server....


This is caused by PHP not loading the MySQL modules. To fix: make sure the file php_mysql.dll (php_mysql.so on non-windows) is in the ext folder of the PHP install; Make sure that the php.ini file that is loaded tells PHP to include that module and that all settings for it are given. Hope this helps.


Better you uninstall all the thing and Just installed all in one package XAMPP while installing almost all the things are configured automatically. Just connect the database.


Its a free open source and easily configured. After installed check with the browser


This is my suggestion.

Thanks for the advice Raja. I installed WAMP 2.1 and everything is working very smoothly. Appreciate the help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.