So I am trying to set up a little script that only allows users to interact with it every 30 minutes - hour or so. I tried something like this:
PHP Code:
<?php $now = time(); $result = mysql_query("SELECT * FROM example WHERE user='$user'") or die(mysql_error()); $row = mysql_fetch_array($result); $last = $row['time']; $timecheck = $now - $last; if ($timecheck < 3600){ // do something // update the time in the table for next time } else { // tell user she can't do that yet } ?>
I get random things though. Negative numbers. It fluctuates and I just can't get it to work reliably. Any suggestions on what to do?
|