iangon — 2010-09-27T19:18:10-04:00 — #1
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!
iangon — 2010-09-28T13:47:38-04:00 — #2
Here is the solution and this code works:
$query="select * from ".$table." where
Date between '".$Begin_Date."' and '".$End_Date."' ";
guelphdad — 2010-09-27T21:57:24-04:00 — #3
Don't put your dates in backticks, it thinks that it is referencing a column, which it isn't.