Reputation: 2866
I have tried some of the solutions from the other questions but am having trouble still. I am throwing another Where clause in and dont know if that is what is messing it up. The following was my last attempt using the suggested CAST from another similar question. MYSQL "date" is formatted correctly.
//set last 3 days for review retrial
$today = date('Y-m-d');
$past = date('Y-m-d', strtotime('-14 days'));
$show_review_query = mysql_query("SELECT * FROM review WHERE status='1' AND entry_date BETWEEN $past AND $today ORDER BY entry_date");
This returns empty.
Upvotes: 0
Views: 638
Reputation: 270637
You need to enclose your dates in single quotes:
$show_review_query = mysql_query("SELECT * FROM review WHERE status='1' AND entry_date BETWEEN '$past' AND '$today' ORDER BY entry_date");
//---------------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^
Be sure to call mysql_error()
, which will point you to the source (if not the cause) of the problem.
$show_review_query = mysql_query("SELECT * FROM review WHERE status='1' AND entry_date BETWEEN $past AND $today ORDER BY entry_date");
if (!$show_review_query) {
echo mysql_error();
}
Upvotes: 1