#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    timestamp auto update


    Hello,

    I asked this question before. Requinix gave me the right answer and a good link. Everything was working, but now it isn't.

    I need to automatically update a timestamp when the row is updated.

    Here is the field timestamp.jpg

    the sql statement looks like this::
    Code:
    $sql="INSERT INTO become_distributor ( business_name,  first_name, last_name, email, phone,  street, city, state, zip, years_in_business, password, questions_comments, date_applied)
    VALUES ('$business_name', '$first_name', '$last_name', '$email', '$phone', '$street', '$city', '$state', '$zip', '$years_in_business', '$password1', '$comments', 'NOW()')";
    Just at the end I use NOW() but the timestamp keeps showing all zeros.

    does anyone know?

    thanks
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    With that ON UPDATE on the field, you don't need to set date_applied yourself. Leave it out of the query entirely and it will be updated on its own.

    The zeroes are because you put the NOW() in quotes, making it a string instead of a function call.

IMN logo majestic logo threadwatch logo seochat tools logo