query works on MySQL, but no in PHP, why?

Macs

New Member
I need to display the results of this query :\[code\]SELECT * FROM projects WHERE PrestaCmd LIKE '% A - CREP - DPE - %'\[/code\]but in PHP, this query doesn't work :sThis is my code :\[code\]$req = "SELECT * FROM ".$table." WHERE PrestaCmd LIKE '%".$ch."%'";echo $req; //returns : SELECT * FROM jos_projectlog_projects WHERE PrestaCmd LIKE '% A - CREP - DPE - %'$results = mysql_query($req);while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) { print_r($row);}\[/code\]I think the problem is coming from the '$ch' variable.But when I put an echo of the query, it's correct, and when I put a query like this : \[code\]$req = "SELECT * FROM jos_projectlog_projects WHERE PrestaCmd LIKE '% A - CREP - DPE - %'";echo $req; $results = mysql_query($req);while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) { print_r($row);}\[/code\]it works :s
 
Back
Top