nepeaNMedia Posted March 10, 2008 Share Posted March 10, 2008 Hi Folks What I want to do is add a date to a table via user input form. If the user does NOT enter a date the variable needs to hold the value of mysql NOW(). I have this code; if(strlen($_POST['expiryDate'])>3){ $expDat = $_POST['expiryDate']; }else{ $expDat = 'NOW()'; } However, when I write $expDat into the query it doe not generate the NOW() value that typing NOW() directly into the query would produce any ideas cheers in anticipation paul Quote Link to comment Share on other sites More sharing options...
revraz Posted March 10, 2008 Share Posted March 10, 2008 NOW is MySQL, not PHP. Just set the default Field paramter for that column to NOW so if nothing passes to it, NOW is the default. Quote Link to comment Share on other sites More sharing options...
nepeaNMedia Posted March 10, 2008 Author Share Posted March 10, 2008 Clever - at 2 am in the morning I did not think of that - thanks Quote Link to comment Share on other sites More sharing options...
nepeaNMedia Posted March 10, 2008 Author Share Posted March 10, 2008 However I seem NOT to be able to set a value of NOW() directly into the table - it reports an error. Does it need to be storeds as timestamp as opposed to date? Quote Link to comment 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.