Just installed PHP/IIS on a fresh 2008 server installation. However, I'm having trouble connecting to my SQL2005 database server. I have good connectivity, and can connect via the Management Studio. Substituting the IP address for the hostname has no effect.
This is the error I get:
Unable to connect.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. [message] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 10.0]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][SQL Server Native Client 10.0]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. ) )
My code is as follows:
<html><body> <?php $server = "dbserver" ; echo $server; $connectionInfo = array("Database" =>"database" ,"UID" =>"sa" ,"PWD" =>"dbpassword" ); /* Connect using SQL Server Authentication. */ $conn = sqlsrv_connect( $serverName, $connectionInfo); if ( $conn === false ) { echo "Unable to connect.</br>" ; die( print_r( sqlsrv_errors(), true )); } sqlsrv_close( $conn); ?> </body></html>
Any help? I'm genuinely stumped.