I have a legacy business application built on MS SQL Server 2000. I have some webbased utilities that access this database using PHP 5.2 with mssql extension.
I need to reinstall the web server, and I looked forward to upgrade to PHP 5.4. Unfortunately, the mssql extension is not supported on PHP 5.3 and newer. There is the sqlsrv extension available form Microsoft, but the description says that it is only supported for accessing SQL server 2005 and up.
How can I connect to my SQL Server 2000 from PHP 5.4 ? Did anyone already solve this issue ?
This is a really complicated issue. Here are the details of (in)compatibilities so someone else might spend less time searching and trying.
sqlsrv exists in two (+ an unofficial) versions, they are only compatible with 32-bit PHP. There is currently no version for 64-bit 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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With