Reputation: 1753
I am trying to put together an MySql query that will return results based on values passed from php. However, the code I am using is throwing an error of 'unknown column in' and then the name of the value in the var $query1. I have obviously gone wrong somewhere and would appreciate some guidance as to correct the error.
I have posted only the relevant code, but would happy to post more if required. Just need to check the error in my statement.
Many thanks.
$searchSql = ($qtype != '' && $query != '' && $query1 != '') ? "WHERE ".$qtype." LIKE '%".$query."%' AND customer = ".$query1."" : '';
Upvotes: 0
Views: 38
Reputation: 16423
Could possibly be due to a missing single-quote around your second criteria:
AND customer = ".$query1.""
Should potentially be:
AND customer = '".$query1."'"
If $query1 is text.
Upvotes: 2