I’m using this code to select some rows with date less than a certain day. When I put <= (less than) in the sql in throws me a fatal error. It works (without error but wrong results) when only adding =.
I’m using PHP-MySQLi-Database-Class from https://github.com/ajillion/PHP-MySQLi-Database-Class
$params = array($id, $day, $day);
$results = $db->rawQuery("
SELECT *
FROM `forecasts`
WHERE `geonameid`=? and (DAY(time_from) <= DAY(?)
OR DAY(time_to) <= DAY(?))", $params);
Fatal error: Problem preparing query (SELECT * FROM
forecastsWHEREgeonameid=? and (DAY(time_from) ) 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 ”
What I am doing wrong?
Looks like it’s PHP-MySQLi-Database-Class problem.
Line 101, function rawQuery
this function strip tags, and result for your query is
so you can just replace this line with