I’m trying to connect to a remote ms sql db (not a localhost), but everytime it timeouts before it sucseeds…
I’m pretty sure that the problem is the $serverName variable, is there anyway to check via Plesk Parallels what is the value of that?
<?php
$serverName = "server's ip address/database name"; //serverNameinstanceName
$connectionInfo = array( "Database"=>"database name", "UID"=>"DBusername", "PWD"=>"DBpassword");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
2
Answers
The problem was that my ip address was not permitted to connect to the database, after I contancted my hosting service provider they gave me that permission and it succeeded.
Try to inject precise port number into ServerName like
Try using Ip address instead NetBios name if you do, cause ICMP protocol is usually blocked due security policy.
Also, the default port 1433 may be blocked. Should contact server administrator to provide actual connection requisits in that case.