Jump to content

failing to connect to remote ms sql server


Recommended Posts

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.