lalnfl Posted October 15, 2010 Share Posted October 15, 2010 How would I put today date for instance into mysql_query? I just want the date and have the format be year, month, day. The format in the database looks like 2010-04-05. That being used as an example. And I have three drop down menus, which you can select the year, month, and day, but it doesn't seem to be working. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2010 Share Posted October 15, 2010 To get today's date, you can just use the mysql CURDATE() function directly in your query. To get help with the dropdown code you tried, you would need to post it along with telling what it did or did not do. Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122355 Share on other sites More sharing options...
lalnfl Posted October 15, 2010 Author Share Posted October 15, 2010 I am getting this SQL query error message: 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 'Show (promo_id, description, name, venue) VALUES ('1' , 'This is a test.' , '' at line 1 Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122360 Share on other sites More sharing options...
lalnfl Posted October 15, 2010 Author Share Posted October 15, 2010 $sql_book_show = mysql_query("INSERT INTO Show (promo_id, date, description, name, venue) VALUES ('$promo_id' , '$show_year,$show_month,$show_day' , '$show_prev' , '$show_name' , '$show_venue')") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122373 Share on other sites More sharing options...
lalnfl Posted October 15, 2010 Author Share Posted October 15, 2010 Anyone know what the problem is? Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122609 Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2010 Share Posted October 15, 2010 show is a reserved keyword. You either need to rename you table to something else or enclose show in back-ticks `` every time you use it in a query. Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122610 Share on other sites More sharing options...
lalnfl Posted October 15, 2010 Author Share Posted October 15, 2010 Thank you very much! Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122613 Share on other sites More sharing options...
phpfreak Posted October 16, 2010 Share Posted October 16, 2010 nice catch Link to comment https://forums.phpfreaks.com/topic/215903-help-with-formatting-date-into-a-mysql-query/#findComment-1122630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.