Getting this error mysql_fetch_assoc() expects parameter 1 to be resource, boolean given when I return my query
$query = mysql_query("SELECT * FROM tempusers
WHERE 'firstname' LIKE '%$data%'
OR 'lastname' LIKE '%$data%'
OR 'description' LIKE '%$data%'
OR 'title' LIKE '%$data%'");
if (! $query){
echo'Database error: ' . mysql_error();
}
while($row=mysql_fetch_assoc($query)){
$description = $row['description'];
echo $description;
}
Specifically, the while loop. Not understanding why I’m getting. I’m thinking it’s because of my use of LIKE, I am unsure if I am using the wildcard's %% correctly with my query. I would appreciate knowing how to rid of this error and why it happened
CONCAT()functionquery,
one more thing, your query is vulnerable with
SQL Injection, please take time to read the article below,