I have a database of MSSQL server 2005. I can connect to the server via MSSLQL client software (MSSQL Management Studio).
The issue is I cant connect to the server from PHP script using the same credentials. And also all mssql configurations are valid in php and apache.
This is the error I receive:
<b>Warning</b>: mssql_connect() [Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: eventsearch.db.7340680.hostedresource.com in /home/horizon/public_html/openivite/server.php on line 2]
PHP:
$this->dblink = mssql_connect(FBSERVER, FBUSER, FBPASSWORD);
All credentials are valid and working.
Advertisement
Answer
Is your web server running on Windows? If so, what version of ntwdblib.dll do you have? See this help page for a much more in-depth explanation.
This error is a pain because it’s not very descriptive. I remember the first time I had to wrestle with it (the problem has been around for at least a few years)… but having the correct DLL makes all the difference in the world.
If you’re trying to connect from a linux box, then you might consider switching from mod_php to php-cgi (or vice versa) as I’ve read success stories from that. But then, I don’t remember ever having this problem when connecting a linux web server to a MSSQL box.