user1532468
user1532468

Reputation: 1753

Mysql statement not returning correct data

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

Answers (1)

Martin
Martin

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

Related Questions