PHP – MS SQL Connection String using a specific port


$server = "serverName\sqlexpress, 1542"; //serverName\instanceName, portNumber (default is 1433)
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
$conn = sqlsrv_connect( $server, $connectionInfo);

if( $conn ) {
echo "Connection established successfully";
}else{
echo "Connection failed.";
die( print_r( sqlsrv_errors(), true));
}

Leave a Reply

Your email address will not be published. Required fields are marked *