Can’t connect to SQL Server 2005 using PHP
I was updating our web application last Friday and I needed it to connect to an SQL Server 2005 Express Edition database to query some tables but my application couldn’t connect to the MSSQL server.
After a few hours of searching the internet and trying different things I finally got it to work by downloading a newer version of ntwdblib.dll (version 2000.80.194.0) and replacing the one that came with PHP 5.2 (we’re using WAMP (Windows, Apache, MySQL, PHP) btw).
In our case, I had to put it in wamp\php, wamp\Apache2\bin, and C:\Wndows\System32.
Also, in your application, don’t forget to add the instance name of the SQL Server in your connection string (eg. server1\instanceName).
Here’s an example connection string for ADOdb (it worked for me without specifying the port number):
‘mssql://admin:password111@webserver01\\SQLEXPRESS/Database1′
I don’t remember the URL where I found this solution, I’ll post it here if I find it again.