PHP Unable to Connect to MS SQL Server Express Edition

I’ve been struggling for several hours to find out why PHP 5.2.5 didn’t want to connect to MS SQL Server 2005 Express Edition although extension=php_mssql.dll already enabled and phpinfo() is showing MS SQL already active.

I always got this error messages when trying to connect to MS SQL:

After doing some searching, I got an answer that PHP 5 is using old ntwdblib.dll version. The one that comes with PHP 5.2.5 distribution is version 2000.2.8.0 which seems doesn’t compatible with the new MS SQL Server 2005 Express Edition. I downloaded new dll from (use the search tool) which is version 2000.80.194.0 and replaced the one on PHP folder with this version.

I use this code to test the connection and its working:

10 thoughts on “PHP Unable to Connect to MS SQL Server Express Edition”

  1. Testing MS SQL connection…
    Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:\SQLEXPRESS in C:\xampp\htdocs\connect.php on line 5
    Connection failed

  2. Hi. I got this problem too. When I try connecting xampp (php version 5.2) with SQL SERVER EXPRESS 2008.
    I have tried many solution such as changing tcp ip, pipe name, static and dynamic port as well as create a system dns, but i still cannot solve it.

    Anyone could help me solve this problem, I would really appreciate.


  3. Thanks a lot for your post , it is quite helpful :)

    I was able finally to solve that problem. I installed Microsoft SQL Server 2000 SP4 , the ntwdblib.dll was at C:\SQL2KSP4\x86\system
    Its version was 2000.80.2039.0 and it solved the problem when I replaced the old ntwdblib.dll with it.

Leave a Reply

Your email address will not be published. Required fields are marked *