Insert Date and Time in MySQL from Dreamweaver


hello,

 

i trying build "leave feedback" form using php , mysql, can't insert date , time database. inserted hidden field form , used dreamweaver "insert record" wizard generated following code:

 

if ((isset($_post["mm_insert"])) && ($_post["mm_insert"] == "frmfeedback")) {
  $insertsql = sprintf("insert feedback (name, email, comments, `date`) values (%s, %s, %s, %s)",
                       getsqlvaluestring($_post['name'], "text"),
                       getsqlvaluestring($_post['email'], "text"),
                       getsqlvaluestring($_post['comments'], "text"),
                       getsqlvaluestring($_post['hdate'], "date"));

 

do have add else code?

 

thanks

you don't put in hidden field, it's impossible know problem is. however...

 

the first thing need realize mysql stores dates , times in 1 format only: iso-recommended yyyy-mm-dd hh:mm:ss. if attempt insert date in other format, mysql stores 0000-00-00 00:00:00. although might seem nuisance, avoids ambiguity of different national customs when storing dates. american 7/4/2009 july 4. european, it's 7 april.

 

so, store date today, must 2009-04-21. other format result in 0000-00-00 date.

 

moving on... today's date want insert? 1 way use datetime column, , insert nothing it. datetime column automatically populated current date , time. automatically update whenever update record. prevent value being updated in update form, retrieve existing value , resubmit in update query.



More discussions in Dreamweaver support forum


adobe

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts