Sample code to connect to an MS SQL database using php

The following is sample code to connect to a MS SQL database using the php MS SQL driver.  On lines two and three, server, dbName, userName and password should be replaced with the connection settings for the applicable database.
Note that the driver works for SQL 2005 and higher, but not SQL 2000.
$serverName "server";
$connectionInfo = array( "Database"=>"dbName""UID"=>"userName""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
     echo "Connection could not be established.<br />";
     die( print_rsqlsrv_errors(), true));
If you run into problems when using this code, please post in our community forum. Technical support is unable to assist with specific coding issues.