I have a little simple problem. I want to perform a query on a Mysql table to select posts posted after a certain date but I don't manage to get it working by setting that date as a PHP variable.
The following query doesn't return anything:
$reqsql = "SELECT * FROM posts WHERE post_date <= " . $from_date;
The "post_date" field is set as a datetime. I have tried everything for the $from_date PHP variable format:
$from_date = date();
$from_date = date('Y-m-d-H-i-s');
$from_date = date('Y-m-d H:i:s');
$from_date = strtodate("now");
None of these work...
But it works fine if I put a basic Mysql date like:
$reqsql = "SELECT * FROM posts WHERE post_date <= NOW()";
Any idea? Thanks!