Troubleshooting for error
Call to undefined function mysql_connect()
while installing PHP5 in windows XP running IIS or Apache


 

 

 

 

 

 

 

Why the error happens:

PHP4 (and below) has MySQL support included by default; the functions are embedded into the core of PHP. But PHP5 has removed embedded support for MySQL and requires MySQL to be loaded as an add-in module, in the same way you have to support anything else. More info can be found the PHP5 Migration FAQ and the Database Issues FAQ.





If you are using Windows XP with IIS
After downloading and installing the PHP 5.0.4  installer ...

1. Open the php.ini file and make the following changes to its contents (php.ini is a text file and resides in C:\WINNT)

Change this : ;extension=php_mysql.dll
to : extension=php_mysql.dll
(the semicolon at the start is removed)
Then give the correct path to the extensions directory
extension_dir = "C:\Program_Files\php\morephp"
(in my case I created a directory called 'morephp' to store all the extensions. If your directory is called 'extensions' the line would be
extension_dir = "C:\Program_Files\php\extensions")





2) Then copy the following files in to the morephp directory (as I have mentioned above, morephp is a name I gave to a directory into which I dump all the extensions):

php_mysql.dll
php_mysqli.dll


The 2 files are available for download here

And... you should live happily ever after!

Remember to restart IIS before viewing pages.



3) Should you still face problems try this. Copy the following files

libmysql.dll
libmysqli.dll


in to

c:\windows\system32

The 2 files are available for download here



4) Still does not work? Try this slightly radical step.
Here is a dump of all the dll files you would possibly need for PHP5 installation. Simply copy all the files from this directory in to your morephp directory.



If your php files simply do not show up on IIS, then check out this
basic tutorial for installing php in IIS, and see what tweaking you need to do in your IIS configuration. The tutorial is of PHP4, but the fundamentals are the same. Here's still another tutorial for the same.


 


If you are using Windows XP with Apache
If you are using Apache instead of IIS, copy the following files

php5apache2.dll
php5ts.dll
php_mysql.dll
libmysql.dll
libmysqli.dll


in to

c:\windows\system32

The 5 files are available for download here

Restart Apache before you view the pages.

Here is another tutorial for installing Php5 in XP and Apache.