Skip navigation
Currently Being Moderated

How to insert date into updated record (MySql, PHP)

Jun 9, 2011 7:15 AM

I want to be able to update an existing record and automatically include the date the change was made when I submit the data back to the MySql database.

 

I saw this thread on how to insert the date on a new record using NOW()

http://forums.adobe.com/thread/855152?decorator=print&displayFullThrea d=true#855152

 

After reading it I successfully amended my insert.php page.

 

Here's the code from my insert.php page which works nicely:

 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO standardsclient_tbl (client_name, pantone_ref1, pantone_ref1_image, font_ref1, font_ref1_image, `date`) VALUES (%s, %s, %s, %s, %s, NOW())",
                       GetSQLValueString($_POST['client_name'], "text"),
                       GetSQLValueString($_POST['pantone_ref1'], "text"),
                       GetSQLValueString($_POST['pantone_ref1_image'], "text"),
                       GetSQLValueString($_POST['font_ref1'], "text"),
                       GetSQLValueString($_POST['font_ref1_image'], "text"),
                       GetSQLValueString($_POST['date'], "date"));

 

 

This is the update.php page, I changed `date`=%s to `date`=NOW() but all this did was stop me from updating the record at all.

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE standardsclient_tbl SET client_name=%s, pantone_ref1=%s, pantone_ref1_image=%s, font_ref1=%s, font_ref1_image=%s, `date`=NOW() WHERE client_ID=%s",
                       GetSQLValueString($_POST['client_name'], "text"),
                       GetSQLValueString($_POST['pantone_ref1'], "text"),
                       GetSQLValueString($_POST['pantone_ref1_image'], "text"),
                       GetSQLValueString($_POST['font_ref1'], "text"),
                       GetSQLValueString($_POST['font_ref1_image'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString($_POST['client_ID'], "int"));

 

 

 

Can anyone see where I've gone wrong?

 

Thanks

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points