Below is a simple PHP script to demonstrate how to connect to a MS SQL database using the php MS SQL driver.
<?php
$serverName = "serverName";
$connectionInfo = array( "Database"=>"databaseName", "UID"=>"userName", "PWD"=>"password", "TrustServerCertificate"=>True);
$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));
}
?>
Article ID: 687, Created: 9/4/2009 at 3:37 PM, Modified: 12/10/2024 at 8:23 AM