Jump to content

select from date field error


EriRyoutan

Recommended Posts

:-\ for some reason, i can't get a select from a date field to work. it always pukes up with an error and says

[code]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 'WHERE day = 20060807' at line 1[/code]

... gee, thanks mr. error message...

anyway, here's a summary of what i've got... and i've got the errors actually trapped, it just takes up a lot of code room...
[code]mysql_query("CREATE TABLE table ( `id` INT NOT NULL AUTO_INCREMENT , `day` DATE, `stuff` VARCHAR( 255 ) NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = MYISAM;
//add fake data to table here...
//none of these work, though...
mysql_query("SELECT * FROM table WHERE day = 20060807;");
mysql_query("SELECT * FROM table WHERE day = '20060807';");
mysql_query("SELECT * FROM table WHERE `day` = '20060807';");
mysql_query("SELECT * FROM table WHERE day = 2006-08-07;");
mysql_query("SELECT * FROM table WHERE `day` = '2006-08-07';");
mysql_query("SELECT * FROM table WHERE `day` = '06-08-07';");
mysql_query("SELECT stuff FROM table WHERE day = 20060807;");[/code]

... glurgh... any ideas?

thank you for reading this, by the way. ^^
Link to comment
Share on other sites

byeh... i figured it out, and it wasn't a problem with the syntax. lets just say i was stupid, and didn't know how to program php.

(i had the bright idea of making a query() function to do mysql_query with the or die() every time, but the problem was that i coded -that- wrong, so... yeah. )

note to others: make sure the problem is the one it tells you to look at...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.