I have this problem with short php code I am using in to get suggestions for JQuery autocomplete. I have tried many things but I am unable to find solution:
//connect to your database
<?php require('Connections/con_1.php');?>
<?php
//retrieve the search term that autocomplete sends
$term = trim(strip_tags($_REQUEST['term']));
//save search queries to csv file
$file = fopen("searchqueries.csv","a");
fputcsv($file,explode(',',$term));
fclose($file);
//query the database for entries containing the term
$qstring ="USE database_2";"SELECT DISTINCT Pracodawca as value FROM Pensje WHERE Pracodawca LIKE '%".$term."%'";
$result = mysql_query($qstring) or die($result.mysql_error());
//loop through the retrieved values
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
//build an array
$row['value']=htmlspecialchars(stripslashes($row['value']));
$row_set[] = $row['value'];
$row['value']=
$row_set[] = array('value' => ($row['value']));
}
//format the array into json data
echo json_encode($row_set, JSON_UNESCAPED_UNICODE);
?>
I get error "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in" and the result is NULL.
What I am doing wrong?