By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

How to Solve: call to undefined function mysql_connect()

The most common solution for a common problem with PHP and MySQL connectivity.

Edited: 2012-07-19 18:29

If you get the error call to undefined function mysql_connect() when trying to connect to MySQL from PHP, you should make sure that the PHP extension directory is setup correctly, and that the mysql extensions are uncommented in php.ini.

The most likely reason for this error, is that PHP isn't loading the MySQL extensions correctly, either because the path for the extensions directory is typed in incorrectly, or because the extension dll is missing from the directory.

How to solve call to undefined function mysql_connect()

To solve this problem, search for extension_dir in php.ini, this is the Directory where the loadable extensions are located. Change this to something like below:

; Directory in which the loadable extensions (modules) reside.
; extension_dir = "./"
; On windows:
extension_dir = "C:\php\ext"

The path should of course correspond to your php installasation.

You should also uncomment the following lines in php.ini.