Page 1 of 1

Periodic "Cannot connect to database"

PostPosted: 15. February 2021 17:59
by shorepatrol
Hi All,

I am using XAMP with PHP hitting a Microsoft SQL database. I've installed the sql_srv drivers, etc - and everything works great!

I am closing the connection after each webpage runs as a best practice.

However, every once in a while the database connection fails, and can only work again when XAMP is completely restarted.

Where do I begin to troubleshoot this?

Re: Periodic "Cannot connect to database"

PostPosted: 15. February 2021 20:03
by shorepatrol
MORE INFORMATION:
This is the actual PHP error received:
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 21 [code] => 21 [2] => [Microsoft][ODBC Driver 17 for SQL Server]Encryption not supported on the client. [message] => [Microsoft][ODBC Driver 17 for SQL Server]Encryption not supported on the client. ) [1] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 21 [code] => 21 [2] => [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection [message] => [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 0 [code] => 0 [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. ) )

Not sure how it can "lose" the instance name randomly, as the instance name is stored in a session variable.