定时资源奇怪的行为

时间:2013-09-11 10:01:45

标签: php mysql

<?php
    $timeNow = time();
    $timeExpire = $timeNow + 2;
    $User = $con->query("SELECT * 
                        FROM players 
                        WHERE Username='".$_SESSION['Username']."'
                        ");
    $UserInfo = $User->fetch_object();

    $con->query("UPDATE players 
                SET Time= '".$timeNow."' 
                WHERE Username='".$_SESSION['Username']."'
                ");

    $con->query("UPDATE players 
                SET TimeExpire= '".$timeExpire."' 
                WHERE Username='".$_SESSION['Username']."'
                ");

        $tt = ($timeNow - $UserInfo->TimeExpire);

        $con->query("UPDATE players 
                    SET Wood=Wood+$tt 
                    WHERE Username='".$_SESSION['Username']."'
                    ");
        $con->query("UPDATE players 
                    SET Stone=Stone+$tt 
                    WHERE Username='".$_SESSION['Username']."'
                    ");
        $con->query("UPDATE players 
                    SET Gold=Gold+$tt   
                    WHERE Username='".$_SESSION['Username']."'
                    ");

        echo $tt;

我有以下代码,当用户注册他的Wood,Stoen和Gold设置为时间戳时,该代码应该为用户提供木材并计算给他们多少钱?我无法弄清楚为什么会发生这种情况,我怀疑以下几行:

    $con->query("UPDATE players 
                  SET Wood=Wood+$tt 
                  WHERE Username='".$_SESSION['Username']."'
                  ");
     $con->query("UPDATE players 
                  SET Stone=Stone+$tt   
                  WHERE Username='".$_SESSION['Username']."'
                  ");
     $con->query("UPDATE players 
                  SET Gold=Gold+$tt 
                  WHERE Username='".$_SESSION['Username']."'
                  ");
?>

0 个答案:

没有答案