致命错误:在第49行的/home/u161146050/public_html/application/views/test1.php中调用非对象上的成员函数fetch_assoc()

时间:2015-04-14 06:24:24

标签: javascript php html css xampp

我有一个关于这个问题的问题...我一直在XAMPP中这样做,没有任何问题..但每当我将它上传到托管时它总是显示这个。

  

致命错误:在第49行的/home/u161146050/public_html/application/views/test1.php中调用非对象上的成员函数fetch_assoc()。

我不知道它出现在line 49的原因,但是在我localhost期间这样做时,它并没有出现。

<table class="table table-condensed table-hover">
    <tr>
        <td class="warning" id="bold">Book Id</td>
        <td class="danger" id="bold">Book Title</td>
        <td class="warning" id="bold">Author</td>
        <td class="danger" id="bold">Status</td>
        <td class="warning" id="bold">Borrower</td>
        <td class="danger" id="bold">options</td>
    </tr>
    <?php
    include('inc/config.php');
    $sql = "SELECT * FROM books";
    $result = $link->query($sql);
    while($row = $result->fetch_assoc()) {
    ?>
    <tr>
        <td class="warning"><?php echo $row['bookNumber']?></td>
        <td class="danger"><?php echo $row['title']?></td>
        <td class="warning"><?php echo $row['author']?></td>
        <td class="danger"><?php echo $row['status']?></td>
        <td class="warning"><?php echo $row['borrower']?></td>
        <td class="danger"><form  method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><div class="btn-toolbar" role="toolbar" aria-label="...">
        <div class="btn-group" role="group" aria-label="...">
            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-bookmark" aria-hidden="true"></span></button></a>
            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></button></a>
        </div>
        </div>
    </form>
</td>
</tr>
<?php    }
?>

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_assoc($result);{