我需要显示此查询的结果:
SELECT * FROM projects WHERE PrestaCmd LIKE '% A - CREP - DPE - %'
但在PHP中,此查询不起作用:s
这是我的代码:
$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);
}
我认为问题来自'$ ch'变量。 但是当我对查询进行回声时,这是正确的,当我提出这样的查询时:
$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);
}
它有效:s
答案 0 :(得分:1)
@ Bahumat100,如果您认为 
有空间造成问题,请使用html_entity_decode
并按照以下方式执行操作:
$req = "SELECT * FROM ".$table." WHERE PrestaCmd LIKE '%".html_entity_decode($ch)."%'";