I've been running SQL Server, IIS and PHP 7.4 on a Windows 10 machine for years with no problem. This is a development machine just for local network. I return to a project in the morning, and I'm no longer connecting to database. Plain HTML and simple PHP scripts still work fine.
Connection could not be established.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][ODBC Driver 17 for SQL Server]SQL Server Network Interfaces: Server doesn't support requested protocol [xFFFFFFFF]. [message] => [Microsoft][ODBC Driver 17 for SQL Server]SQL Server Network Interfaces: Server doesn't support requested protocol [xFFFFFFFF]. )
[1] => Array
(
[0] => HYT00
[SQLSTATE] => HYT00
[1] => 0
[code] => 0
[2] => [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
[message] => [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
)
[2] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => -1
[code] => -1
[2] => [Microsoft][ODBC Driver 17 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 17 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.
)
)
- I turned off firewall
- Checked Services to see that all SQL Server services were running
- Restarted Default Web Site in IIS
$serverName = "DESKTOP-HRTJKQ7\SQLEXPRESS"; //serverName\instanceName
// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
if($_SESSION['DataBase']=="TestDB") {
$connectionInfo = array( "Database"=>"TestDB", "ReturnDatesAsStrings" => true);
} else {
$connectionInfo = array( "Database"=>"LiveDB", "ReturnDatesAsStrings" => true);
}
// }
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
// echo "Connection established.<br />";
$ConnectionEstablished = "<strong>CNCT</strong>";
$_SESSION['ConnectionEstablished'] = $ConnectionEstablished;
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
What am I missing?