hvad er der galt her:
Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in...
if (isset($_GET['q'])) {
$searchTerms = explode(' ', $_GET['q']);
$searchTermBits = array();
$params = array();
foreach ($searchTerms as $term) {
$term = trim($term);
if (!empty($term)) {
$searchTermBits[] = "Firstname LIKE ? OR Surname LIKE ?";
$params[] = "%" . $term . "%, %" . $term . "%";
}
}
$sql = 'SELECT Firstname, Surname FROM Person WHERE ' . implode(' OR ', $searchTermBits);
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query( $conn, $sql, $params, $options);
$array = array();
while($fetch = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
$array[] = array('Name' => $fetch['Firstname'] . ' ' . $fetch['Surname']);
}
echo json_encode($array);
sqlsrv_free_stmt($stmt);
}