MS server 2008 R2 PHP connecting to SQL2000

Sorry, yes! Sometimes helping backfires! Hmmm…

Well, I looked around and found this on StackOverflow. It was in response to someone who was having your same problems. Might help explain and it shows connection strings near the end…
This is a really complicated issue. Here are the details of (in)compatibilities so someone else might spend less time searching and trying.

PHP extension sqlsrv from Microsoft

sqlsrv exists in two (+ an unofficial) versions, they are only compatible with 32-bit PHP. There is currently no version for 64-bit PHP.

  • sqlsrv version 2.0 is compatible with PHP 5.2.4 to 5.3.x and SQL Native client 2008 R2 to connect to Microsoft SQL Server 2000, 2005, or 2008.
  • sqlsrv version 3.0 is compatible with PHP 5.3.0 to 5.4.x and SQL Native client 2012 to connect to Microsoft SQL Server 2005, 2008, 2008 R2, and SQL Server 2012.
  • no official version currently supports PHP 5.5
  • There is an unofficial version of SQLSRV 3.0 on Rob’s Area that does not require SQL Native client 2012 but should run with previous SQL Native clients. I didn’t yet try this one.

ODBC extension of PHP

An other way to access SQL Server 2000 with PHP 5.4 is through the odbc extension. It is possible to connect using three ODBC drivers for SQL Server 2000:

  • SQL Server ODBC client version 6.00 that comes preinstalled with Windows 2008 R2
  • SQL Server Native Client 9.0 (SQL Server 2005 feature pack)
  • SQL Server Native Client 10.0 (SQL Server 2008 R2 feature pack)

The code for the connection for each of those ODBC Drivers:

$connection_string = 'DRIVER={SQL Server};SERVER=mbsql;DATABASE=vg1';
$connection_string = 'DRIVER={SQL Native Client};SERVER=mbsql;DATABASE=vg1';
$connection_string = 'DRIVER={SQL Server Native Client 10.0};SERVER=mbsql;DATABASE=vg1';
$connection = odbc_connect( $connection_string, $user, $pass );

These connections work with PHP 32 bit and 64 bit. I din’t yet test which one is the best.

so maybe the “SQL Server ODBC client version 6.00 that comes preinstalled with Windows 2008 R2” is the way to try
which would mean using $connection_string = 'DRIVER={SQL Server};SERVER=mbsql;DATABASE=vg1';

Let us know your results…

the problem is getting PHP 5.4 installed and working.
as I said, there is no MSI installer for v5.4.x and when i downloaded the ZIP and followed the instructions to install and configure it, it wouldn’t work.

i continually got the could not open input file: o error when trying to check it was working.

Well, I looked at the php.net archives and found they have all the installers for all versions.
I downloaded version: php-5.4.3-Win32-VC9-x86.zip and opened the zip to see if there was an installer inside it. There was. It is named php-win… Here is the link to their archives… PHP archives

Hope it helps…

php-win.exe is not an installer file.

i don’t know what i’ve done, but i fiddled about and it’s now working using the original connection method (ie not the ODBC).

php 5.3.29 using sqlsrv_connect

Well, interesting! Well, as they say around here… " If it works, don’t fix it! " Ha!

Glad it is working for you finally. Doubt I helped much, but, very glad you solved it. I bet some update you did changed some setting or file.

i’ll need to try and replicate it on another server so that i know what is required to make it work.

Sponsor our Newsletter | Privacy Policy | Terms of Service