justice_at_night Posted May 18, 2015 Share Posted May 18, 2015 Hello everyone, In brief: OK so the problem itself: I have created a db.php file to connect from the IIS server to the SQL server, but I keep running into issues. At first I would get an http 500 error on the page and not see anything else. Then I made some changes and it came up with a "error locating server/instance specified" error (found below). Made some more changes and it came back to the http 500 error. Further details: I have a 4 server setup I'm trying to make work. Two of the servers are running IIS and two are running a failover cluster of microsoft sql server. (This may not be the correct way to say it sorry). Server 1: IIS Server 2: IIS Server 3: MS SQL Server 4 MS SQL I have already setup those servers. What I am trying to do now is connect to a database on Server 3 from Server 1 using php. I have installed "PHP 5.6.0" and the "Microsoft Drivers 3.2 for PHP v 5.6 for SQL Server in IIS" from Web PI. I have also set up FastCGI module mapping inside of the IIS manager. db.php file i am testing... $serverName = "(SERVERNAME\SERVERINSTANCE)"; //$uid = "(user)" //$pwd = "(password)" $connectionInfo = array( "Database"=>"databasename"); //$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"databasename"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } //----------------------------------------------- // Perform operations with connection. //----------------------------------------------- /* Close the connection. */ sqlsrv_close( $conn); ?> Running this file with the correct server name, instance name, and database name gets me: Connection could not be established. Array ( [0] => Array ( [0] => 08001 [sqlSTATE] => 08001 [1] => -1 => -1 [2] => [Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [message] => [Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. ) [1] => Array ( [0] => HYT00 [sqlSTATE] => HYT00 [1] => 0 [code=auto:0] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired [message] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired ) [2] => Array ( [0] => 08001 [sqlSTATE] => 08001 [1] => -1 [code=auto:0] => -1 [2] => [Microsoft][ODBC Driver 11 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 11 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. ) ) Can someone please help me? I will provide more information if asked for. I am new to this but I want this to work and have been unable to do so up to now. Quote Link to comment https://forums.phpfreaks.com/topic/296379-failing-to-connect-to-remote-ms-sql-server/ Share on other sites More sharing options...
justice_at_night Posted May 18, 2015 Author Share Posted May 18, 2015 Oh shoot i think i posted this in the wrong section.... Quote Link to comment https://forums.phpfreaks.com/topic/296379-failing-to-connect-to-remote-ms-sql-server/#findComment-1512153 Share on other sites More sharing options...
Barand Posted May 18, 2015 Share Posted May 18, 2015 "\" is the escape character so you may need "\\" in the server name (or try "/" ) Quote Link to comment https://forums.phpfreaks.com/topic/296379-failing-to-connect-to-remote-ms-sql-server/#findComment-1512168 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.