簡単なSQL文を作成しようとしています:
// build sql statement
$sql = "select * from some_tbl where ";
if(strlen($mydetails['city']) > 0) {
$sql .= "cityname in (".$mydetails['city'].") and ";
}
$sql .= 'fromdate <= expirydate and expirydate >= curdate() order by rand()';
しかし、$sql には < と > の間のすべてがありません。デバッガーは $sql の値を次のように表示します。
select * from tbl_adsinfo where fromdate = curdate() order by rand()
これはとても基本的なことで、迷ってしまいます。< または > は特殊文字だと思いませんよね? それらをエスケープして、代わりに二重引用符を使用しようとしましたが、同じです。
どうしたの?