I've upgraded my php installation to 5.4.14 using Microsoft's Web Platform Installer 4.6.

Php is working great except I cannot connect to my database.

My connection was working great before the upgrade, but now it will not work. Here is my connection string where is my real IP address:

$db = new PDO("odbc:DRIVER={SQL Server};SERVER=;DATABASE=TEST;charset=utf8", "TEST", "Password");

This causes the browser to bring up a page that says "server error" but my error log remains empty. In my php.ini file, I have these lines:


These extensions do not appear to my phpinfo.php page. My "extension_dir" variable is set to the correct directory.

UPDATE: Now my error log is populating (for reasons unknown) and I am getting this error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\v5.4\ext\php_pdo_sqlsrv.dll' - The specified module could not be found.

I was not able to get a SQL connection working on php 5.4.14, but I was able to downgrade to 5.3 and get it working. I learned a lot along the way and I wanted to post here to help others that come after.

About my environment: Windows Server 2003 IIS version 6.0 SQL server 2005, located on another machine.

Instructions for installing PHP 5.3.xx: 1. Uninstall any previous php versions that you are not using. You can have more than one PHP version installed at the same time.

  1. Install Microsoft's Web Platform Installer 4.6. http://www.microsoft.com/web/downloads/platform.aspx

  2. Once installed, run it and go to the Applications tab.
    -Search for "php". -Install PHP version 5.3.xx AND "Microsoft Drivers for PHPv5.3 for SQL server in IIS"

  3. Download the "Microsoft Drivers 3.0 for PHP for SQL Server", SQLSRV20.EXE, from http://www.microsoft.com/en-us/download/details.aspx?id=20098. This is very important that you select the SQLSRV20.EXE package and not the SQLSRV30.EXE package. "Install" the SQLSRV20.EXE package anywhere. You will be copying two drivers from this directory in step five. -Note: For anyone downloading the SQLSRV30.EXE for a different installation configuration and that gets the error "SQLSRV30.EXE is not a valid Win32 application", you can get around this by using 7-zip and unextracting it's contents. (You can treat the .exe like an archive.)

  4. Navigate to your PHP installation directory (in my case, C:\PHP\v5.3). Then enter the "ext" directory.
    -Delete two files: "php_pdo_sqlsrv.dll" and "php_sqlsrv.dll" -Copy these two files, "php_pdo_sqlsrv_53_nts_vc9.dll" and "php_sqlsrv_53_nts_vc9.dll", from the direcotry that you installed the SQLSRV20.EXE package.
    -Note: In the file name for the driver, "nts" means "non-thread safe", vc9 is the environment which was used to compile the driver/php, and "53" correlates to the version of php in use (in this case, php version 5.3.whatevertheminorversionis). You should ALWAYS install the non-thread safe version in Windows. Microsoft's Web Platform Installer does this for you.

  5. Open your php.ini file (Located in the root directory of where PHP is installed. In my case, this was C:\PHP\v5.3\php.ini) delete these two lines which will be near the end of the file:



    And add these two lines:



  6. In IIS, add you php applications to a pool if not already done, right click on the pool and hit recycle. You should be good to go!
    -You can also attempt to restart the IIS admin service

TROUBLESHOOTING My application that I was running my phpinfo.php page was not in a php application pool. It was running under an ASP.net application pool. After moving my php application to its own pool and restarting the application pool the SQL driver showed up.

You may need to configure the fcgiext.ini file in C:\WINDOWS\system32\inetsrv. Under the types section, you should have listed something like "php=PHP53_via_FastCGI" and then "[PHP53_via_FastCGI] ExePath=C:\Program Files\PHP\v5.3\php-cgi.exe"

"php=PHP53_via_FastCGI" should correlate to the PHP installation you want in IIS. If you had another section for "PHP54_via_FastCGI" and you want to use PHP 5.4 for pages, then you should change this value to "php=PHP53_via_FastCGI".

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.