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
https://forums.phpfreaks.com/topic/16823-select-from-date-field-error/
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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.