I have my first PHP project and I can connect to a SQL server database on my local SQL Server express but when I attempt to connect to a remote connection it fails. This is the connection that works locally;
$serverName = "IT90334\SQLEXPRESS, 1433";
But I have tried the following connections;
$serverName = "servername\MSSQLInstancename, 40009";
$serverName = ""server.I.P.Address\MSSQLInstancename, 40009";
$serverName = "//server.I.P.Address\MSSQLInstancename, 40009";
$serverName = "//server.I.P.Address\MSSQLInstancename";
$serverName = "server.I.P.Address"
$serverName = "server.I.P.Address:40009"
They output an error to the browser that initially states one of the following;
Provider: No such host is known Error Locating Server/Instance Specified and Timing out Named Pipes Provider: Could not open a connection to SQL Server
Then the next part of the error states;
A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections
I can telnet to the server using this command
C:\telnet servername 40009
But it still won't connect. What am I missing here? Below is a section of the PHP and obviosuly I am looking for the "Connection established" to be shown in the browser
$serverName = "servername\MSSQLInstancename, 40009";
$connectionInfo = array('Database' => 'AuditDEV');
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn) {
echo "Connection Established.<br />";
} else {
echo "Something went wrong while connecting to MSSQL.<br />";
die(print_r(sqlsrv_errors(), true));
}
Aucun commentaire:
Enregistrer un commentaire