Tuesday, July 29, 2008

PHP Startup: Unable to load dynamic library --- Specified module could not be found.

Another WAMP error to deal with.

In this case, seeing the PHP error "Fatal error: Call to undefined function: mysql_connect() in some_random_script.php"

Turns out that under PHP 5, the MySQL libraries are no longer included by default. However, the installer package can add them in for you, no problem.

There are multiple reasons this issue shows up, and many of them are explained in the comments section of the official PHP Installation of Extensions on Windows page.

The problem is likely due to one (or both) of the following reasons: 1) You've had a previous installation of PHP or MySQL, and you have older .DLL files scattered about your hard drive, or 2) PHP doesn't know where to find the DLL's.

Here are the fixes:

For the first issue, remove the following old files from your Windows\System32 folder:

  • libeay32.dll
  • ssleay32.dll
  • libmysql.dll

You'll already have the newer versions of those file in your PHP installation folder.

The next step is to make sure that the PHP installation folder is in your system's PATH variable. It doesn't matter if you don't know what that means... simply follow these instructions:

  1. Bring up the "System Properties" window by either pressing Windows-Break on your keyboard, or by right-clicking on "My Computer" and selecting properties.

  2. Select the "Advanced" tab.

  3. Click the "Environment Variables" button at the bottom.

  4. Under "System Variables" at the bottom, scroll down to "Path" and click "edit".

  5. Look for the location of your PHP installation (something like C:\PHP, C:\Program Files\PHP or C:\Progra~1\PHP.

  6. If you don't see your PHP installation folder, add a semi-colon ";" and then the folder of your PHP installation folder.

  7. Close out of all those windows and reboot

Note that this will not fix things until you reboot. As far as I know, there's no way to get Windows to reload the System Variables without a reboot.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home