dsb238100 2017-04-23 09:43
浏览 317

致命错误:未捕获错误:在布尔值|上调用成员函数fetch() 仅限网络服务器

The line saying <?php while ($row = $arne->fetch()) { ?> Seems to be working totally fine in localhost server with: 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>

But when using it on a webserver: Picture: webserver setup

I get the error:

Fatal error: Uncaught Error: Call to a member function fetch() on boolean in /var/www/html/php/pages/statistics.php:15 Stack trace: #0 /var/www/html/php/index.php(82): include() #1 {main} thrown in /var/www/html/php/pages/statistics.php on line 15

Line 15 is not line 15, but the line containing:

<?php while ($row = $arne->fetch()) { ?>

Thanks for help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?