RE: How to connect to MS SQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
caseymanus
Forum Commoner
Posts: 34
Joined: Wed Nov 20, 2002 10:32 pm
Contact:

RE: How to connect to MS SQL

Post by caseymanus »

One thing you will find is that if you are using SQL Server 2000 you cannot use the existing MS SQL function in PHP. They will only work with SQL Server 7 I have found. What I suggest is using the unified ODBC driver and related functions...ie

Code: Select all

$conn =  odbc_connect($dsn, $username, $password);
$RS = odbc_exec($conn, "select * from table");
Of course this requires setting up a system dsn pointing to a specific database.

If you are on unix/linux box connecting to mssql it can be a pain, because you cant set up a dsn, but you have to mimic it with system variables. I am sure there is some documentation on how to do that, but I dont have time to look it up.
Post Reply