pedrobcabral Posted February 25, 2007 Share Posted February 25, 2007 SQL query: ALTER TABLE `contact` CHANGE `date` `date` DATETIME NOT NULL DEFAULT 'now()' MySQL said: #1067 - Invalid default value for 'date' I would like to display defaultly the present time, can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/40084-easy-now-doubt/ Share on other sites More sharing options...
btherl Posted February 26, 2007 Share Posted February 26, 2007 Try removing the quotes from now(). The string 'now()' is in invalid format for a date, but the value returned by the function now() will be a date. Quote Link to comment https://forums.phpfreaks.com/topic/40084-easy-now-doubt/#findComment-193980 Share on other sites More sharing options...
fenway Posted February 26, 2007 Share Posted February 26, 2007 You can't default to an expression... just add the column, then run an update... and just use NOW() in your inserts. I've wanted this feature on DATETIME columns forever, but they won't do it. Quote Link to comment https://forums.phpfreaks.com/topic/40084-easy-now-doubt/#findComment-194453 Share on other sites More sharing options...
pedrobcabral Posted February 26, 2007 Author Share Posted February 26, 2007 I'm trying to do something like: $date = now(); And insert on the query to mySQL the variable date, the problem is that is getting me the following error: Call to undefined function now() - it's the line I've stated above. One more thing, to evaluate if the user has filled the form I'm cheking if some ($_POST[vars]) are set. This part does work but it gives my in my log the following: Use of undefined constant email - assumed 'email' in bla bla bla. Why the hell? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/40084-easy-now-doubt/#findComment-194837 Share on other sites More sharing options...
fenway Posted February 27, 2007 Share Posted February 27, 2007 Sounds like the quoting is wrong, and php is complain that there's no PHP now() function. As for the post error, I have no idea... not enough info. Quote Link to comment https://forums.phpfreaks.com/topic/40084-easy-now-doubt/#findComment-195359 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.