php mysql form date query help
I am trying to do a mysql database lookup by passing a begin date and end date from an html form. I have a date column in my database which is written to using the php function date("Y-m-d"); The date column is currently formatted as a mysql DATE field. The goal is to allow the user to lookup customer rows based between a begin and end date.
Here is my string, which fails:
$query='select * from '.$table.' where Date between `'.$Begin_Date.'` and `'.$End_Date.'` ';
the error message returns:
Unknown column '2010-09-03' in 'where clause'
Any help would be much appreciated - I need to get this project done!
Here is the solution and this code works:
$query="select * from ".$table." where
Date between '".$Begin_Date."' and '".$End_Date."' ";
Don't put your dates in backticks, it thinks that it is referencing a column, which it isn't.