计时器 java 脚本在本地服务器上运行良好。但是当我在托管服务器上运行它时,它不会启动计时器。
<script type="text/javascript" >
<?php
$elapsed=time()-strtotime($_SESSION['starttime']);
if(((int)$elapsed/60)<(int)$_SESSION['duration'])
{
$result=executeQuery("SELECT " .
" TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%H') as hour, ".
" TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%i') as min, ".
" TIME_FORMAT(TIMEDIFF(endtime,CURRENT_TIMESTAMP),'%s') as sec ".
" FROM studenttest ".
" WHERE stdid=".$_SESSION['stdid'].
" AND testid=".$_SESSION['testid'].";");
if($rslt=mysql_fetch_array($result))
{
echo "var hour=".$rslt['hour'].";";
echo "var min=".$rslt['min'].";";
echo "var sec=".$rslt['sec'].";";
} else {
$_GLOBALS['message']="Try Again";
}
closedb();
} else {
echo "var sec=01;var min=00;var hour=00;";
}
?>
</script>