Markus Blog What’s going on Internet?

2Jun/085

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");
}
Bookmark and Share

Related Article

Comments (5) Trackbacks (0)
  1. Thank you very much for this post, you save me from a looong struggling with this issue! ^_^

  2. Hi Darsch, glad that my post can help you :)

  3. Thanks! Just what I was looking for :)

  4. Thanks for the post. It worked well.

  5. Hi Lorien, glad it helped you :)


Leave a comment


*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

No trackbacks yet.


Sideblog feed

  • Mozilla Released Thunderbird 3 9 December 2009
    The long waited open source email client Thunderbird 3 is now released! Upgrading from Thunderbird 2 to Thunderbird 3 is very easy and almost automatically. Once you finished installing version 3, you. […]
  • Microsoft Wireless Comfort Desktop 5000 Keyboard and Mouse 22 October 2009
    The Microsoft Wireless Comfort Desktop 5000 has been designed to enhance your Windows 7 experience. You can easily access programs in the task bar with convenient hot keys. Applications in the taskbar. […]
  • WooFunction: 178 Amazing Web Design Icons 28 September 2009
    The WooFunction Icon Set includes 178 amazing web-related icons in a sophisticated and glossy design style. All 178 icons are available as 32×32 pixel PNG files and we can assure you that they are in. […]
  • Moblin the Next Generation OS for Netbook 27 September 2009
    Moblin is an open source project that supports Linux-based software platform and is optimized for the next generation of mobile devices including netbooks, mobile Internet devices (MIDs), in-vehicle i. […]
  • Twitterify Your Wordpress Blog Using P2 Theme 21 September 2009
    Twitter is becoming more and more popular due to its requirement as micro blogging is not much, only 140 characters that even less than a text message limit which is 160 characters. Blogger that is no. […]