Page 1 of 1

sql syntax error

Posted: Wed Feb 15, 2006 8:29 pm
by jasondavis
ERROR: 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 '21:21:04 ORDER BY enddate asc' at line 1

Here is the code I am trying to do

Code: Select all

$currentdate = date("Y-m-d H:i:s");
my query

Code: Select all

$query = "SELECT MSid,email,startdate,enddate,amount FROM payed_users WHERE enddate > $currentdate ORDER BY enddate asc";

Alsoo when I output $currentdate I get something like this
2006-02-15 21:21:04 and in my DB for the row endate they are in the format of 2006-02-06 15:46:17


so what am I doing wrong

Posted: Wed Feb 15, 2006 8:47 pm
by Christopher
I think the date should be quoted like:

Code: Select all

$query = "SELECT MSid,email,startdate,enddate,amount FROM payed_users WHERE enddate > '$currentdate' ORDER BY enddate asc";