说明<?php while ($row = $arne->fetch()) { ?>
的行似乎在localhost服务器上完全正常工作:
Picture: localhost setup
<?php
$arne = $db->query("SELECT *, AVG(correct_answers) AS average FROM result r, quiz q WHERE r.quiz_id=q.id GROUP BY quiz_id ORDER BY average");
?>
<h1>Average Score</h1>
<div id="table-wrapper">
<div id="table-scroll">
<table>
<tr>
<th>Quiz</th>
<th>Result</th>
<th>Questions</th>
</tr>
<?php while ($row = $arne->fetch()) { ?>
<tr>
<td><a href="/quiz/<?=$row["quiz_id"]?>"><?=$row["name"]?></a></td>
<td><?=floor($row["average"]*100 / $row["question_count"])?></td>
<td><?=$row["question_count"]?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
但在网络服务器上使用时: Picture: webserver setup
我收到错误:
致命错误:未捕获错误:在/var/www/html/php/pages/statistics.php:15中调用boolean上的成员函数fetch()堆栈跟踪:#0 / var / www / html / php / index.php(82):在第15行的/var/www/html/php/pages/statistics.php中抛出include()#1 {main}
第15行不是第15行,而是包含以下内容的行:
<?php while ($row = $arne->fetch()) { ?>
感谢您的帮助!