0

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?

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • Did you check the protocols as in [THIS ANSWER](https://stackoverflow.com/questions/13238219/sql-server-express-cannot-connect-error-28-server-doesnt-support-requested-p) ? – Zak Sep 14 '22 at 20:30
  • Have you checked that nothing has been updated/upgraded? It's not particular common that things just "breaks" unless there's been _some_ change somewhere. It could have been some security update for the OS or SQL Server, someone changed some configuration somewhere. – M. Eriksson Sep 14 '22 at 20:32
  • Thank you Zak! I'd looked at that earlier, but I quit after everything checked out under "Client Protocols". My issue was in "SQL Server Network Configuration". All is good now. – Fifth Leg Sep 14 '22 at 20:47

0 Answers0