Good day. I use PDO. There is a query like:
SELECT * FROM tbl_ads AND ad_price>:minprice AND ad_price>:maxprice ORDER BY ad_parse_date DESC LIMIT 0,10 Next, I execute the query as follows:
if($minprice!=""&&$maxprice!=""){ $where = $where." AND ad_price>:minprice AND ad_price<:maxprice"; $fields[":minprice"] = $minprice; $fields[":maxprice"] = $maxprice; } $stmt = $pdo->prepare($query); foreach($fields as $key => $value) { $stmt->bindParam($key, $value); } $stmt->execute(); When this occurs, an error of the form:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND ad_price>'1000000' AND ad_price>'1500000' I see that the sign> and <is replaced by the corresponding gt and lt. How can this be overcome?