Php mysql form date query help

php mysql form date query help

hello all-

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.'` ';

echo mysql_error();

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!

Much Thanks!

Here is the solution and this code works:

$query=“select * from “.$table.” where Date between '”.$Begin_Date.“’ and '”.$End_Date."’ ";

Thanks Guys!

Don’t put your dates in backticks, it thinks that it is referencing a column, which it isn’t.