If you have PHP5 and MySQL installed on Windows you may find that when you goto connect to mysql you'll get an error message like the following:
Why do I get the call to undefined function error message when connecting to mysql?
How do I solve this? Whats wrong with PHP5?
Fatal error: Call to undefined function mysql_connect() in [path of script here] on line [line number here]
Now this error may come as a suprise for some people that have migrated from PHP4 to PHP5 and immediately think PHP5 is broken. This is not the case. In actual fact there has been a license change between PHP and MySQL. PHP no longer embeds MySQL support into PHP as of PHP5. Instead what you need to do is simply enable the mysql extension. Once you've done that you'll be able to use any of the mysql functions within PHP.
Okay first locate your php.ini file which is most probably located in either the windows folder (C:\WINDOWS), the system folder (C:\WINDOWS\SYSTEM32), or in your php folder. If it isn't in any of those folders simply do a quick search for it, if windows still cannot find it chances are you haven't created it yet. To do so simply goto your php installation folder (C:\php, defualt path) and find a file called php.ini-recommended now copy this to the Windows folder and rename it to just php.ini.
Once you have found your php.ini file, open it and find the following line:
extension_dir = "./"change this line to the following:
extension_dir = "C:\php\ext"What this line does is tells PHP where all your PHP extensions are located to.
NOTE: Change C:\PHP to the actuall path of your PHP folder if it is not located in the root of the hard drive, I used this as by defualt PHP is extracted/installed there
Now scroll down abit further and find the following line:
;extension=php_mysql.dllremove the semi-colon from infront of that line to enable the mysql extension.
Once you have done that save your php.ini and restart your server. When you goto use mysql_connect() again you shouldn't get any errors.
If you do get an error when you restart your server or use the mysql_connect function then make sure you have configured the path of the php extension folder and that you have successfully restarted the sercer correctly. Also make sure you have copied a file called libmysql.dll to the windows folder too. Once you have copied the file restart your sever again. This should now enable mysql support.
If you get no errors when you connect to mysql through php then you have successfully enabled the mysql extension!
I hope this has solved your problem with connecting to mysql with PHP5.
Also this FAQ can be used to enable mssql, msql and other database extensions too!