Page 1 of 1

adding a timer until the database info changes

Posted: Sat Jun 25, 2005 7:06 am
by mickd
hi, i was wondering how you could say for example someone presses a button, then a timer starts which for example 2 hours later changes the database information. like say field1 in table1 has a value of 10. someone submits a form in which 2 hours later would change field1 to 20 from 10.

any help appriciated greatly.

Posted: Sat Jun 25, 2005 2:29 pm
by Ambush Commander
MySQL doesn't have these capabilities, you'll have to use Cron or something similar to simulate what you are requesting.

Posted: Sat Jun 25, 2005 5:02 pm
by Burrito
Ambush Commander wrote:you'll have to use Cron or something similar to simulate what you are requesting.
exactly, just write out a crontab file to execute whatever you want on whatever interval you specify.

try a google for "crontab file examples" and I'm sure you'll find plenty.

Posted: Mon Jun 27, 2005 1:00 am
by mickd
hi, sorry for the slow reply, after looking at some site on google about it, i have a few questions.

on the sites it says crons are written in the format:
minute hour day month year(some say day of week here) command

1. can we write php/mysql codes where it says command? if so do we write the whole code there including the <?php ?> tags?
2. if you dont do it like that, do you just write the code into a .php file and where it says command specify where the file is?
3. sorry if these are noob questions but i was wondering what file extension cron files get saved as? is it just .cron?

thanks for any help, greatly appriciated.

Posted: Mon Jun 27, 2005 10:43 am
by Burrito
you can NOT just write php code in the crontab file. YOu have to execute a php file from there (probably best to use the CLI).

Posted: Tue Jun 28, 2005 12:32 am
by mickd
k, thanks for the reply. grealy apprciated.