2Jun/087
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:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: (local)\SQLEXPRESS in path\mssql.php on line 5
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 http://webzila.com (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:
echo("Testing MS SQL connection... "); if ($conn = mssql_connect('(local)\SQLEXPRESS', 'user', 'pass')) { echo("Connection succeed"); mssql_select_db('dbname', $conn); mssql_close($conn); } else { echo("Connection failed"); }
July 16th, 2008 - 15:33
Thank you very much for this post, you save me from a looong struggling with this issue! ^_^
July 30th, 2008 - 01:41
Hi Darsch, glad that my post can help you
May 16th, 2009 - 02:02
Thanks! Just what I was looking for
September 16th, 2009 - 16:17
Thanks for the post. It worked well.
September 16th, 2009 - 19:02
Hi Lorien, glad it helped you
March 25th, 2010 - 17:45
Great it helped
July 29th, 2010 - 19:10
Testing MS SQL connection…
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 202.131.123.188\SQLEXPRESS in C:\xampp\htdocs\connect.php on line 5
Connection failed