I am trying to connect to my database by IP using this code:
$serverName = "195.181.245.55,49163\BCPLIUS2017";
$connectionInfo = array(
'Database' => 'dbname',
'UID' => 'dbuser',
'PWD' => 'dbpass');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if($conn){
echo "Database connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r(sqlsrv_errors(), true));
}
I can connect without any problems with HeidiSQL client using exact data that I use in my php script.
With php connection I get this error
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 10013 [code] => 10013 [2] => [Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: An attempt was made to access a socket in a way forbidden by its access permissions. [message] => [Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: An attempt was made to access a socket in a way forbidden by its access permissions. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired [message] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 10013 [code] => 10013 [2] => [Microsoft][ODBC Driver 11 for SQL Server]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. For more information see SQL Server Books Online. [message] => [Microsoft][ODBC Driver 11 for SQL Server]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. For more information see SQL Server Books Online. ) )
What I am doing wrong?
I'am sure that server allow remote connections