paulmo Posted December 16, 2008 Share Posted December 16, 2008 want to post date/time of form execution in db field. thanks Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/ Share on other sites More sharing options...
gevans Posted December 16, 2008 Share Posted December 16, 2008 Do you have any code yet? This isn't a place to get free work, we're here to help solve problems Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717189 Share on other sites More sharing options...
flyhoney Posted December 16, 2008 Share Posted December 16, 2008 Just use the mysql NOW() function. example: INSERT INTO table SET created = NOW() Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717198 Share on other sites More sharing options...
paulmo Posted December 16, 2008 Author Share Posted December 16, 2008 yikes! (was writing reply while previous posted. that NOW function seems so easy. how does it know what table to go to?) i need to post date/time in same table row as the following when the form's submitted: mysql_connect("xxx", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $name = mysql_real_escape_string($_POST['name']); $theme = mysql_real_escape_string($_POST['theme']); mysql_query("INSERT INTO interactive (name, theme) VALUES ('$name', '$theme') ") or die(mysql_error()); i'm reading about date (format, [timestamp]); but unsure how to start. would "created" in example above be the date/time field in table? thank you!! Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717201 Share on other sites More sharing options...
flyhoney Posted December 16, 2008 Share Posted December 16, 2008 Something like this? mysql_connect("xxx", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $name = mysql_real_escape_string($_POST['name']); $theme = mysql_real_escape_string($_POST['theme']); mysql_query("INSERT INTO interactive (name, theme, created) VALUES ('$name', '$theme', NOW()) ") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717203 Share on other sites More sharing options...
paulmo Posted December 16, 2008 Author Share Posted December 16, 2008 very cool, thanks! missing the time though. easy fix? Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717208 Share on other sites More sharing options...
flyhoney Posted December 17, 2008 Share Posted December 17, 2008 Make sure the created column is a mysql DATETIME Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717209 Share on other sites More sharing options...
paulmo Posted December 17, 2008 Author Share Posted December 17, 2008 you're the greatest! so simple. seems that php, mysql, js, all can do similar things, but this one has to win for simplicity. i'm guessing it's all gleaned from the mysql manual? i'm referring to that, but defintions can seem cryptic to a noob without knowing the applications. thanks again! Link to comment https://forums.phpfreaks.com/topic/137269-posting-datetime-of-form-usage-to-mysql-db/#findComment-717217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.