Connect to MSSQL database with PHP 5.6.4

I have a server that is running Windows Server 2008 R2, 64-bit.  It has PHP 5.6.4 installed on it running via IIS7.  I'm trying to connect to a SQL database that resides on a different server.  There is no official SQL extension for PHP 5.6.4 so I have downloaded one that I found here that others seem to have success with.  I still can't get my script to connect.  

I've tried connecting to the SQL server from yet another server running an older version of PHP for which there is an official PHP SQL extension and it connects without a problem.  I'm even able to successfully telnet to the SQL server on port 1433 and it answers.  Therefore, I know there's not a problem connecting to the remote SQL server due to a networking issue.

To test whether or not I'm able to connect, I have the following in my script:
$serverName = "<<SERVER IP ADDRESS>>";
$uid = "login";
$pwd = "password";
$connectionInfo = array( "UID"=>$uid,"PWD"=>$pwd,"Database"=>"Database_name");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if($conn)
{
    echo "works";
}
else 
{
    echo "fails";
}

Open in new window


I have E_ALL & ~E_DEPRECATED set for error_reporting and display_errors is set to On.  I get no errors whatsoever.  All i get is "fails".

What is it that could be holding me up?

The attached image shows the pertinent sections from running phpinfo on the server that is running 5.6.4.  I've compared these sections to the server running the older version of PHP and they are the same.
PHP-5.6.4-SQL.jpg
brstoresAsked:
Who is Participating?
 
gr8gonzoConsultantCommented:
Sorry, then. I run a SQL Server / PHP app, but there's been no reason for me to update past 5.3 yet, so I'm still using the official driver.

However, ODBC should definitely work. In fact, that's probably the most reliable long-term solution, since it's a generic driver that is not specific to any PHP version. I would give that another try.
0
 
gr8gonzoConsultantCommented:
I would just use version 3.1 of this driver:
https://www.microsoft.com/en-us/download/details.aspx?id=20098

Worst case, use ODBC.
0
 
brstoresAuthor Commented:
I've tried that driver, it didn't work either.  There was an error in the message log stating that the version of the SQL extension didn't match the version of PHP.

I've never had any luck with ODBC.  I guess I've only really ever tried it once, but for some reason or another, I couldn't get it working.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.