MS server 2008 R2 PHP connecting to SQL2000

Well, you said you were upgrading to 2008, so I assumed… Me-Bad!
The bad news is: (From a note on StackExchange)

SQL Server 2000 is not supported on Windows Server 2008 . If you simply must run it, I suggest building a VM with Windows Server 2003 and installing SQL 2000 on that instead. If you mess up your Windows Server 2008 , don’t go crying to Microsoft. They will not be able to help you .Sep 15, 2012

Now, with that said. If you need a FULL SQL server, you would have to buy it. But, MS has an Express version that handles most small tasks. Per MS:

Microsoft SQL Server Express is a version of Microsoft’s SQL Server relational database management system that is free to download, distribute and use. It comprises a database specifically targeted for embedded and smaller-scale applications.

It is free and easy to download from their site. I guess your choices are move back to Windows Server 2003 or either install the 2008 Express version for free or purchase a newer SQL Server version.

Hope that helps…

we defintely have confused wires here.

the SQL2000 server is not on the same server as 2008 R2 server - two separate boxes.
i did clarify this in my last post.

windows server 2008 r2 64 bit - this is the IIS server.
SQL server 2000 running on its own server - windows 2003 server 32-bit.

IIS running on the 2008 R2 server with PHP installed, with PHP connecting to the SQL 2000 database.

Well, all that takes us full circle back to the top again.
You do not have the correct Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver installed. Looking at your original post, I went to the link provided by MS and it says you need at least PHP 5.4 minimum.
And, it says for 5.4, you need PHP-SQLsrv version 3.2 (I think you have 5.3?)
And, for version 3.2, you need at least ODBC Driver version 11

Not sure! Their link is hard to follow. I think it appears to be the ODBC driver, or the driver for PHP under Windows. Looking a few clicks into that link in the error message, it clearly states that driver 5.4 will run under Windows 2008 v2 and with PHP 5.4, BUT NOT with PHP 5.3.8… So, you might have to upgrade to PHP 5.4 at least. Here is that link: (Read system requirements.) PHP Connection to SQL2000

Not really full circle as I’m NOT using SQL 2008. the error may say that but that’s not the version of SQL in use.

The only 2008 version of anything in using is the IIS server.

SQL is on its own server and that is SQL 2000 running on Windows server 2003 32 bit.

What I meant is you are using a SERVER 2008. IIS is a function on top of that.
Next, you are using PHP 5.38.

That is 100% okay from what I know.

BUT, to use that setup and call-out to a SQL 2000, you can NOT do it!
You need at lease PHP 5.4…

Hope that helps explain it better…

which one of the numerous 5.4.x builds though i wonder…

i downloaded php-5.4.0-nts-Win32-VC9-x86.zip, but for the life of me i can’t get it to work at all.
there isn’t an MSI installer like there was with v5.3.x.

i unzipped it to C:\php, amended the php.ini as per (https://docs.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-on-iis/install-and-configure-php), configured IIS.

ran php -info from the command prompt but i just get “could not open input file: o”
so i’ve gone from a working PHP with no SQL connection to no working PHP at all.

update

i couldn’t get 5.4.0 to work at all, so have reverted to 5.3.29 (via MSI installer).
i am now getting a different error message, which suggests i maybe further forward in getting this working

Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'. ) [1] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database requested in login 'Siclops_CTS_Live'. Login fails. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database requested in login 'Siclops_CTS_Live'. Login fails. ) [2] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'. ) [3] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database requested in login 'Siclops_CTS_Live'. Login fails. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database requested in login 'Siclops_CTS_Live'. Login fails. ) )

https://ctspalmtop.uk/php.php
https://ctspalmtop.uk/test.php

now it looks like it’s an authentication problem, but the user and password are defintely correct (when i put a wrong password in i get different error message saying the password is incorrect).

Well, I looking at php.net, it appears you can only get 5.6 and up from their Windows download area.
It is here: PHP.net Windows Download
Then, run the php-win file for Windows. BUT, it appears it is connecting now, so don’t think this is needed!
Just appears to be a username or password issue now. It is saying user “SA” and your user is

Microsoft says with the SQLSTATE of 28000 and Error of 18456 you need to read this:
SA connection error 28000-18456 Not sure if this pertains…

it doesn’t pertain in this instance, as the SQL server is already set what that link suggests.

Well, not sure what to suggest. Seems you need to upgrade to 5.6? Hmmmm…

but then that won’t support connecting to SQL 2000?
aren’t i limited to what version of PHP i can use when connecting to SQL 2000 ?

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