I have the following code:
function query_tip($title,$desc)
{
$q1=("SELECT id, company, name FROM abc
where ('$title' LIKE CONCAT('% ',company,' %') or
'$desc' LIKE CONCAT('% ',company,' %') or
'$title' LIKE CONCAT('% ',name,' %') or
'$desc' LIKE CONCAT('% ',name,' %'))
AND company != ''
AND name != ''");
$r1=mysql_fetch_array($q1);
$id=$r1['id'];
return $id_nse;
}
Here, $title is containing data like "my name is anna" and $desc is having data like "I am a programmer at xyz company and I work on the PHP platform."
However, it is giving this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /bin/whatever on line 2005
but when I run this query on a command prompt or in my database, it runs fine with no error.
Why is this query giving an error when I run it via PHP?