mssql php

46

<?php
$serverName = "serverName\\sqlexpress"; //serverName\instanceName

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"dbName");
$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));
}
?>

$dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");

$hostname may need to be configured as either...
$hostname.':'.$port;
$hostname.','.$port;

Comments

Submit
0 Comments