3

I just installed Apache 2.2.17, PHP 5.2.14, and MySQL 5.1.51 on Windows XP. Apache is working and is loading PHP properly, but when I try to connect to MySQL, I get "Fatal error: Call to undefined function mysql_connect()". After some googling, I found that I need to load the php_mysql.dll extension, which requires libmysql.dll. I found the libmysql.dll file in the MySQL distribution, but php_mysql.dll is nowhere to be found.

Why is it not included with PHP or MySQL? Where can I find it?

2

The file http://windows.php.net/downloads/releases/php-5.2.14-Win32-VC6-x86.zip as downloaded from http://windows.php.net/download/ does include php_mysql.dll. It's in the "ext" subdirectory.

You'll need to rename php.ini-recommended to php.ini. Then, edit php.ini and make sure that extension_dir is pointing to the correct directory, i.e. the one containing php_mysql.dll, e.g. c:\php\ext. Also, search for the line ;extension=php_mysql.dll and uncomment it to enable the extension.

Lastly, the file libmysql.dll should be available to the Windows system PATH. The easiest way to accomplish that is by adding the directory to which you installed PHP to your PATH.

Remember to restart Apache after making changes to php.ini. Hope this helps!

  • I copied that file into the php directory and now httpd crashes when I try to connect to the database. At least I have the DLL now! Thanks – Graeme Perrow Oct 27 '10 at 19:06
2

MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Although copying libmysql.dll to the Windows system directory also works (because the system directory is by default in the system's PATH), it's not recommended.

PHP/MySQL Installation manual

  • Yes, I've already read all of that. It says "the php_mysql.dll DLL must be enabled inside of php.ini" but I don't have php_mysql.dll. – Graeme Perrow Oct 27 '10 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.