danposs86 Posted April 11, 2007 Share Posted April 11, 2007 i am using a form to add data to a mysql database using php. I am using the following code for the query: mysql_query("INSERT INTO `site_news` (news_name, news_title, news_post) VALUES ('$_SESSION[user]', '$_POST[title]', '$_POST[news]')"); what i want to do is get the form to add the date in (in the form of DD-MM-YYYY ideally). The field is called 'news_testdate' and is set as a date.I am guessing it will be something like this: mysql_query("INSERT INTO `site_news` (news_name, news_title, news_post, news_testdate) VALUES ('$_SESSION[user]', '$_POST[title]', '$_POST[news]'), 'NOW()'"); or something along them lines.Any ideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 11, 2007 Share Posted April 11, 2007 Remove the quotes around NOW, you want to execute the function, not store the text "NOW()". Link to comment Share on other sites More sharing options...
danposs86 Posted April 11, 2007 Author Share Posted April 11, 2007 i managed to work out a different way, which i think will work excellently in the long run: $news_date = date("d-m-Y");mysql_query("INSERT INTO `site_news` (news_date, news_name, news_title, news_post) VALUES ('$news_date', '$_SESSION[user]', '$_POST[title]', '$_POST[news]')"); thanks anyway mate Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now