#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    St. Louis, Missouri, USA
    Posts
    2
    Rep Power
    0
    I'm using cookies to customize an index page once a user has created an account and I have a last_visited DATETIME variable in a user table that I want to update every time the user visits the site. I set
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $new_last_visited = $new_last_visited = date("m-d-Y H:i:s", (time()));
    [/code]
    Then I send a query like so to update the date.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $query = "UPDATE account SET last_visited='$new_last_visited' WHERE ID=$user_id";
    [/code]
    well... it sets the date to 0000-00-00 00:00:00 and I have no clue why. Please help!!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Malmö
    Posts
    13
    Rep Power
    0
    try without the '-sign. I've had the same problem myself.

    $query = "UPDATE account SET last_visited=$new_last_visited WHERE ID=$user_id";
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    St. Louis, Missouri, USA
    Posts
    2
    Rep Power
    0
    zreo,
    I've tried it without the ' and it doesn't work. I've tried the following:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    set last_visited='$new_last_visited'
    set last_visited=$new_last_visited
    set last_visited="$new_last_visited"
    [/code]
    nothing works. it still updates it to 0000-00-00 00:00:00 Does anyone have a solution??

    Thanks
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    9
    Rep Power
    0
    Hi @vantageIT,

    are you sure your query-string is correct? Add the following to your script<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>echo $query;[/code]If the query is correct, check to see if the mysql-account you use is allowed to do updates!

    Bye,

    Marc aka Foddex

    ------------------
    ++++++++++++++++++++++++++++++++++++++++
    ceterum censeo linguam c++ esse delendam

Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 11:50 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 04:54 PM
  3. Change this PHP script to use NETPBM instead of GD
    By hknight in forum Project Help Wanted
    Replies: 1
    Last Post: February 10th, 2004, 12:46 PM
  4. Need help with this PHP script (update a table)
    By crazyIvan in forum PHP Development
    Replies: 11
    Last Post: February 6th, 2004, 06:08 AM
  5. Replies: 1
    Last Post: February 4th, 2004, 02:39 PM

IMN logo majestic logo threadwatch logo seochat tools logo