http://www.php.net/manual/en/sqlsrv.installation.php
and downloaded the drivers to my ext directory I then added these two lines in my php.ini file
extension=php_pdo_sqlsrv_53_ts_vc9.dll
extension=php_sqlsrv_53_ts_vc9.dll
Finally after restarting I tried this simple connection
- Code: Select all
<?php
/* CONNECT TO THE DATABASE */
$connectionInfo = array('UID'=>'', 'PWD'=>'', 'Database'=>'dia2');
/*USE DB CONNECTION ABOVE TO CONNECT TO THE SERVER */
$conn = sqlsrv_connect('brksvp306\BRKSQL01', $connectionInfo);
/* STORE SQL IN A VARIABLE */
$sql = "SELECT stcname, shipto FROM DIA2.dbo.dealers ORDER BY stcname";
/* RUNNING THE SQL */
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "<BR>SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
?>
only to get this error
Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in F:\xampp\WebPages\PR\PartReviewResultsms.php on line 14
SQLSTATE: IMSSP
code: -14
message: An invalid parameter was passed to sqlsrv_query.
Running
XAMPP 1.7.7
Windows Server 2003 sp2
PHP Version 5.3.8