PHP & MySQL (UPDATE statement)

Discussion in 'PHP' started by vlad230, Dec 27, 2009.

  1. #1
    Hello guys!

    I'm currently working on a script that should empty a field in a database every 24h.

    list($hour, $minute, $second) = explode(":", date("H:i:s", time()));
    $empty = "";
    if( (intval($hour) == 0) && (intval($minute) == 0) && (intval($second) == 0) ){
    	mysql_query("UPDATE `contest` SET 24h_ips='".$empty."' ");
    }
    PHP:
    The problem is that I thought it will execute even if no one accesses the page (@ 00:00:00), but it seems that I was wrong.... In order to execute someone has to access the page in that precise moment....

    Is there some way to make it execute even if no one accesses the page at that time?

    Thanks a lot,
    Vlad
     
    vlad230, Dec 27, 2009 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Yes its called a 'cron job'. Search either google or these forums for that prhase. Essentially, it will execute the script you posted above at a precise time.
     
    plog, Dec 27, 2009 IP
  3. gaven

    gaven Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah, if you have cpanel it's pretty simple to set one up
     
    JAY6390, Dec 27, 2009 IP
  5. vlad230

    vlad230 Active Member

    Messages:
    544
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    95
    #5
    Thanks guys, I've managed to set one up :)
     
    vlad230, Dec 27, 2009 IP