With no success I spent several hours a couple weeks ago attempting to get PHP 5.2.4 on a Windows Apache web server to talk to an MS SQL 2005 Server that was installed as an instance on a server running an older version of MS SQL. I was able to connect to the default instance of MS SQL server running on the machine, but nothing I did would allow it to connect to the named instance running 2005.
Returning to this project today with fresh eyes I found the two key bits of information that I had previously overlooked. I am now able to talk to the MS SQL instance from my PHP application. The most frustrating issue was a change in PHP that I picked up by using the newest version of PHP. PHP apparently changed how it handles the server name in the mssql_connect function, which was not made apparent in any documentation, blogs, or discussion groups that I could find. The source of the other problem is documented on the PHP website, but somehow I happened to overlook it while researching this problem.
Listed below are these two bits of information reproduced from the two sources. Hopefully this will be useful to anyone else that finds themselves pulling their hair out over this same issue.
From PHP.net (http://www.php.net/manual/en/ref.mssql.php)
The extension requires the MS SQL Client Tools to be installed
on the system where PHP is installed. The Client Tools can
be installed from the MS SQL Server CD or by copying
ntwdblib.dll from
\winnt\system32 on the server to
\winnt\system32 on the PHP box.
Copying ntwdblib.dll will only provide access
through named pipes.
Configuration of the client will require installation of all the tools.
From hadrien(dot)debris {at} gmail(dot)com Posted on php.net
I have lost one day to understand why the MSSQL<->PHP connection
was no longer functioning after a PHP update (5.2.2->5.2.4).
I eventually found how to solve things:
BEFORE
$link = mssql_connect("SERVER\INST", "LOGIN", "password");
Which does not work any longer.
AFTER
$link = mssql_connect("SERVER\\INST", "LOGIN", "password");
Works flawlessly.
Hope that'll prevent someone to lose precious hours of exasperation.