tags:

views:

206

answers:

4

Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database. But all the query work is done on the client side, I'd like to move some of this to PHP.

What driver and/or connection string is needed to connect to Sql Svr and what is the syntax to use in PHP?


Update: OK so I was definitely trying to avoid using anything to do with copying DLLs etc. I'll look into the SQL2K5PHP driver (thanks Vincent). @jcarrascal for the sake of clarity, by "client side" I mean our application is an internal web app that runs as an HTA, with all queries done via javascript calls to an ASP which actually submits the DB request.

A: 

PHP provides an extension for accessing Microsoft SQL Server databases. To use the SQL Server extension, all that is required is to activate the extension in the PHP configuration file.

Details on the MSDN page

Espo
+2  A: 

Hi Scott.

Just use the mssql_connect() function like this:

$conn = mssql_connect('localhost', 'sa' , '123456')
    or die('Can\'t connect.');
mssql_select_db('database', $conn)
    or die('Can\'t select the database');

Functions relating to SQL Server are defined in the PHP manual for the MSSQL driver.

One question though, "all the query work is done on the client side" WTF? :D

Julio César
+3  A: 
Vincent
A: 

I came across this today and it has summarised things nicely.

Scott Bennett-McLeish