<?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']."'
");
?>