0

I'm using the Zend CE server with PHP 5.3.5 and Eclipse Helios with PDT to develop a database-driven PHP web application. I have my dev environment setup and enabled the SQL_Srv driver through the Zend control panel.

My problem is in my script when I call the sqlsrv_connect() function, it fails to connect to my SQL Server db and always returns false. I've verified I can connect to the server through a System DSN as well as Microsoft SQL Server Management Studio, so I know it's there and I can talk to it. These same settings also work on my coworker's dev environment (the same as mine), so I'm not sure what's missing. Has anyone else had similar issues with the PHP SQL Server driver? The relevant snippet of code:

$serverName = 'dbServer';
$connectionInfo = array ( "Encrypt" => 0, "LoginTimeout" => 10,  "Database" => "Test_DB", "UID" => "ABC", "PWD" => "123" );

//This is always false.  Does not connect
$test_Connect = sqlsrv_connect ( $serverName, $connectionInfo );

$GLOBALS['_connection'] = sqlsrv_connect ( $serverName, $connectionInfo );

if ( $GLOBALS['_connection'] == false ) {
    print_r ( sqlsrv_errors(), true );
    die ( "Failed to connect to SQL Server '$serverName'." );
}
2
  • Do a phpinfo() to make sure that PHP has the necessary SQL Server extensions compiled in. Commented Jun 27, 2011 at 21:20
  • Hi Jarrod, yes I checked phpInfo(), I can see "sqlsrv" in the list of registered PHP streams. Commented Jun 27, 2011 at 21:36

1 Answer 1

1

Turns out PHP SQLSrv driver requires the Microsoft SQL Server 2008 Native Client to function. Make sure it's the '08' client and not '05', I already had the native client for SQL Server 2005 installed while experiencing this issue. It was only after I installed the client for SQL Server 2008 that it worked properly. Hope this helps others.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.