我是 php 初学者,在找出为什么我的代码不断抛出解析器错误时遇到了问题。希望你们能帮帮我。
错误出现在代码的末尾,并且是“Unexpected ,expecting while (T_WHILE)”代码在这里...
<html>
<?php
$db = new PDO('mysql:host=localhost;dbname=testit;charset=UTF-8', 'testit', 'testit', array(PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$stmt = $db->query("SELECT * FROM TestTable");
$amdata = array();
$ctrinner = 0;
$ctrouter = -1;
$prevweek = "9999";
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) do {
if ($prevweek !== $row['WeekNumber']) {
$ctrouter++;
$ctrinner = 0;
$amdata[$ctrouter][$ctrinner] = 'week: "'+$row['WeekNumber']+'"';
}
$ctrinner++;
$amdata[$ctrouter][$ctrinner] = $row['XAxisCategory']+': '+$row['YAxisValue'];
$prevweek = $row['WeekNumber'];
}
// Whatever comes aftert this line throws a php error 'Unexpected <whatever I put there>, expecting while (T_WHILE)....'
// Even if I put nothing it complains about Unexpected '?>' expecting while (T_WHILE) ?>
?>
</html>