BrianM Posted May 30, 2008 Share Posted May 30, 2008 How do I enter the current date in this format -- mm-dd-yy -- in this query? mysql_query("INSERT INTO `".$_POST['projectnumber']."` (Date) VALUES ('".echo date(m-d-y)."')"); That is what I have right now, and is not working :| Quote Link to comment https://forums.phpfreaks.com/topic/108064-solved-current-date-as-value/ Share on other sites More sharing options...
BillyBoB Posted May 30, 2008 Share Posted May 30, 2008 You forgot your quotes. <?php mysql_query("INSERT INTO `".$_POST['projectnumber']."` (Date) VALUES ('".echo date("m-d-y")."')"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/108064-solved-current-date-as-value/#findComment-553900 Share on other sites More sharing options...
Darklink Posted May 30, 2008 Share Posted May 30, 2008 No no no. Echo is used to display your string on the screen. You are just processing information here. <?php mysql_query("INSERT INTO ".$_POST['projectnumber']." (Date) VALUES ('" . date("m-d-y") . "')"); ?> You need to wrap your date() parameter with quotes aswell. I'm not sure if you can use Date as a fieldname. But if that works, then I guess you can. Quote Link to comment https://forums.phpfreaks.com/topic/108064-solved-current-date-as-value/#findComment-553902 Share on other sites More sharing options...
PFMaBiSmAd Posted May 30, 2008 Share Posted May 30, 2008 Storing a date as mm-dd-yy in a database will result in the most painful experience for you and if your Date field happens to be a DATE data type, will result in invalid data (you will probably get 0000-00-00 in the database.) Once you switch to use a standard DATE format, mysql has a CURDATE() function that returns the current date directly in the query statement. Quote Link to comment https://forums.phpfreaks.com/topic/108064-solved-current-date-as-value/#findComment-553904 Share on other sites More sharing options...
BrianM Posted May 30, 2008 Author Share Posted May 30, 2008 Thanks you very much for you help, suggestions and assistance. Problem solved! Quote Link to comment https://forums.phpfreaks.com/topic/108064-solved-current-date-as-value/#findComment-553910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.