我想根据用户所处的阶段设置等待时间。我只是想快速测试一下并把这个:
function towait(){
if ($query = mysql_query('select fase, lastone from users where id = "'.$_SESSION['id'].'"')){
while($r[]=mysql_fetch_array($query));
if ($r[0]['fase'] == 0) {
$wait = 0;
} elseif ($r[0]['fase'] == 1) {
$wait = 300;
} elseif ($r[0]['fase'] == 2) {
$wait = 600;
} elseif ($r[0]['fase'] == 3) {
$wait = 900;
} elseif ($r[0]['fase'] == 4) {
$wait = 1500;
} elseif ($r[0]['fase'] == 5) {
$wait = 2100;
} elseif ($r[0]['fase'] == 6) {
$wait = 2700;
} elseif ($r[0]['fase'] == 7) {
$wait = 3600;
} elseif ($r[0]['fase'] == 8) {
$wait = 5400;
} elseif ($r[0]['fase'] > 8) {
$wait = 7200;
} else {
$wait = 0;
}
if((time() - $r[0]['lastone']) > $wait) {
//go ahead
$go = 1;
} else {
//you have to wait
//I know this looks weird, but I just save the hour when OK to go as a string in the format "HHuMM"
$go = date("H", ($r[0]['lastone'] + $wachten + 60)) . "u" . date("i", ($r[0]['lastone'] + $wachten + 60));
}
return $go;
} else {
$go = -1;
return $go;
}
}
奇怪的是,在第 7 阶段之前一切正常,但只要用户处于第 7 阶段,它就会停止工作(脚本不会让用户等待)。第 8 阶段也是如此。在第 9 阶段和 9+ 阶段,一切都恢复正常。
我知道这听起来很疯狂(而且代码写得不好),但我想知道是什么导致了这件事。