View Full Version : Connecting to MSSQL on Windows

07-11-2005, 03:49 PM
this is the ASP connection string I would normally use to connect to the SQL Server but I'm not sure how to convert this into a format that I can use in PHP to connect to the db.
We're running PHP 5 on IIS and I'm trying to connect to SQL Server 7

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=databasename;Data Source=NAK-HQ-DEV-01;Current Language=british;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=HQ-NAK-WS-01;

07-11-2005, 11:41 PM
mssql_connect($host, $username, $password);

- Basically it's like using mysql_connect(), just replace the mysql_ with mssql_ :). The same goes for the other db functions.

Make sure the MSSQL extension is enabled (uncommented) in php.ini.

07-12-2005, 09:02 AM
...I'd kinda got that far but what do I put as the host?

also where would I find the php.ini?

07-12-2005, 09:28 AM
nevermind, just asked my boss if I could change the php.ini file and he said he's going to install mySQL... there was some reason that he didnt really explain but I'm not complaining lol...

07-12-2005, 11:25 AM
The host would be "localhost" if the webserver is on the same machine as the MSSQL server.

php.ini is usually found in c:/windows/ (or c:/winnt).