homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Connecting to SQL Server 2005

 4:59 pm on Nov 5, 2007 (gmt 0)

This is driving me up the wall: why does PHP not want to connect to the local SQL Server? I've got some ASP.NET apps that connect to it fine, but with PHP, it just says it can't connect to the server. Is there anything I need to configure? It's PHP running off CGI on IIS on a Windows box with MSSQL Server Express 2005 installed.



 7:56 pm on Nov 5, 2007 (gmt 0)

Make sure Named Pipes and TCP/IP connections are enabled on SQL server 2005--this is the most common reason for connection failure, as both are disabled by default on a fresh install.


 10:04 pm on Nov 5, 2007 (gmt 0)

Yep they're on!


 10:22 pm on Nov 5, 2007 (gmt 0)

In that case, are you sure that the PHP MSSQL extension was installed?

Also make sure that you're connecting to "localhost/SQLEXPRESS" (or whatever your SQL server instance name is). Connecting directly to localhost probably won't work for a SQL Express installation unless you changed a few defaults.

If all this fails, try replacing ntwdblib.dll in your PHP folder with an older version (there's a known issue with the current version distributed with the Windows PHP installation), then restart IIS for good measure.


 10:48 pm on Nov 5, 2007 (gmt 0)

Where do I get this older version from?


 3:55 am on Nov 6, 2007 (gmt 0)

I don't have a link off-hand--I remember finding it in the user comments for the documentation of the mssql_connect() function on php.net.


 8:18 pm on Nov 6, 2007 (gmt 0)

I just got this link in a MSDN Flash e-mail:

Microsoft SQL Server 2000/2005 Driver [microsoft.com]


 8:03 pm on Nov 8, 2007 (gmt 0)

Yeah I've seen that, but I don't know whether to install it.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved