wouwouke Posted October 30, 2006 Share Posted October 30, 2006 As you will read below, I'm a real noob on this... and trying to make some dynamism on my website...I know how a user can insert data into a field in a form, and then input this information into the database. But for a datetime variable (in mysql), I don't seem to find a way to insert data... I tried using a text field where the user inputs something like '2006-11-01 15:15:15', but this does not seem to work. Could anyone provide me some code to insert dates via a form in a mysql database?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/25573-insert-information-in-form-for-datetime-variable/ Share on other sites More sharing options...
fenway Posted October 30, 2006 Share Posted October 30, 2006 That should work just fine... what code are you using now? Quote Link to comment https://forums.phpfreaks.com/topic/25573-insert-information-in-form-for-datetime-variable/#findComment-116836 Share on other sites More sharing options...
jake2891 Posted January 6, 2011 Share Posted January 6, 2011 yeah i just tested that code on a mysql db and it works for me. can you put a or die(mysql_error()) on your query and see what it says. show us your insert statement. heres my example one i used just for testing not to make code secure and nice etc... <?php $conn = mysql_connect("***","***","***"); mysql_selectdb("testsql"); $timestampInSeconds = $_SERVER['REQUEST_TIME']; $mySqlDateTime= date("Y-m-d H:i:s", $timestampInSeconds); mysql_query("insert into hello (`test1`)values('$mySqlDateTime')"); $q = mysql_query("select * from hello"); while($row = mysql_fetch_array($q,MYSQL_ASSOC)){ echo $row['test1']."<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/25573-insert-information-in-form-for-datetime-variable/#findComment-1155572 Share on other sites More sharing options...
jake2891 Posted January 6, 2011 Share Posted January 6, 2011 lol this post was posted in october haha dont think he'd be seeing our replies now. Quote Link to comment https://forums.phpfreaks.com/topic/25573-insert-information-in-form-for-datetime-variable/#findComment-1155574 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.