sql syntax error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jasondavis
Forum Commoner
Posts: 60
Joined: Sat Feb 04, 2006 5:35 pm

sql syntax error

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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";
(#10850)
Post Reply