i try to query MSSQL Server. The query is very simple but still get only errors. The version of PHP is 7.0.28 and code is here:
$serverName = "(local)";
/* Connect using Windows Authentication. */
try
{
$conn = new PDO("sqlsrv:server=$serverName ; Database=mgm59ood", "sa", "********");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($conn)
{
$tsql = "select name from goods";
$getResults = sqlsrv_query($conn, $tsql);
// Error handling
if ($getResults == FALSE)
{
die(FormatErrors(sqlsrv_errors()));
}
}
}
catch(Exception $ex)
{
die(print_r($ex->getMessage()));
}
In my browser throw exception in line with $getResults.
Fatal error: Uncaught Error: Call to undefined function sqlsrv_query() in C:\xampp\htdocs\testwithsql\index.php:26 Stack trace: #0 {main} thrown in C:\xampp\htdocs\testwithsql\index.php on line 26
Please help me.