I've been through almost all the solutions listed for connecting php to microsoft SQL server.
I'm using windows 64 bit machine with xampp installed and trying to connect to microsoft sql server management studio.
I've added php_pdo_sqlsrv_72_ts.dll and php_sqlsrv_72_ts.dll to C:\xampp\php\ext
I've also added the below lines to php.ini available in C:\xampp\php\php.ini :
extension=php_pdo_sqlsrv_72_ts.dll ;added on 03-09-2018 for connecting to ms sql extension=php_sqlsrv_72_ts.dll ;added on 03-09-2018 for connecting to ms sql
However, i keep getting the Fatal error
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\test.php:14 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 14
<?php
$serverName = "XXXX";
$uid = "abcd";
$pwd = "Abcd1234";
$databaseName = "databasename";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$tsql = "SELECT * FROM SRC_transaction";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
echo "Statement executed.<br>
";
}
else
{
echo "Error in statement execution.
";
die( print_r( sqlsrv_errors(), true));
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>