PHP MSSQL 2005 Problem – Solved

2 Comments

Trying to make a connection to a MS SQL Server 2005 database from PHP, I always got an error message using the mssql_connect saying:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: {servername}.

I tried several solutions like, updating the ntwdblib.dll (on windows; I had the same error on linux) library, configuring the tcp/ip properties on sqlexpress but nothing I still having the same error.

At the end I changed the ip address on the server name by the respective server name and finally worked!.

So instead of:


$server = 192.168.50.1;
$user = 'sa';
$password = 'sapassword';
$conn = mssql_connect($server, $user, $password);

Changed for:

$server = cmanonserver;