I am trying to count logins by date range by counting how many times the auto integer (id) appears between a start and end date.
I get the start date and end date from a form in a previous page (y-m-d).
$start_date=$_POST['start_date']; /*in this case its "2014-10-10"*/
$end_date=$_POST['end_date']; /*in this case its "2014-10-20"*/
$sql = <<<SQL
SELECT id, COUNT(*) as login_count FROM `usage`
GROUP BY id
WHERE date
BETWEEN $start_date AND $end_date
SQL;
However I keep getting the following syntax error
"There was an error running the query [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 'WHERE date BETWEEN 2014-10-10 AND 2014-10-20' at line 3]"
What am I doing wrong?