MS SQL


How do I connect to MSSQL using PHP?
$db = ADONewConnection('odbc_mssql');
$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
$db->Connect($dsn,'userid','password');

See the descriptive one

<?php
//Code for connection
$myServer = "localhost";
$myUser = "Database User Name"; // replace with your values
$myPass = "Database Password"; // replace with your values
$myDB = "Database Name"; // replace with your values

//create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection")
or die("Cannot start ADO");

//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
?>