I am using the current code in attempt to access a msSQL 2005 db:
Late response, but it might help someone.
we are nearly there, it is the problem with your connection parameters,
probably you need to give servername as IP:port
servername:: The MS SQL server. e.g. hostname:port (Linux), or hostname,port (Windows).
Server Name should be "server\instance"
An instance is nothing more than specific port address different than 1433... so just discover the port on mssql server and then try to connect using: ip:port
Example code that works completely fine for me::
ini_set('display_errors', '1');
// $myServer = "winsrv22.somedns.co.uk:22320";//this style works as well
$servername = "123.21.47.23:22320";
$myUser = "UserName";
$myPass = 'xxxxxxxx';
$myDB = "[database]";
//connection to the database
$dbhandle = mssql_connect($servername, $myUser, $myPass)
or die("Couldn'tt connect to SQL Server on $myServer");
if($dbhandle) {
echo "Success, Connected\r\n";
} else {
echo "problem :( \r\n";
}
Hope this helps some one :) Happy coding!!