How to connect to a MS SQL database in PHP

The server name, DB name and DB user name can be found in the Databases/MS SQL section of Control Panel.

PHP is not enabled by default. See: How to enable PHP for my Everleap site account.
 
<?php
$serverName = "Enter Host Name";
$uid = "Enter Username";
$pwd = "Enter Password for SQL User";
$databaseName = "Enter name of the Database";

$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>$databaseName);

/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>