Php 警告:mysqli_fetch_array()要求参数1为mysqli_结果

Php 警告:mysqli_fetch_array()要求参数1为mysqli_结果,php,Php,我一直试图显示我的数据库,但我就是无法让它工作。 谢谢你的帮助。我已经尝试了3个多小时,但一无所获 <table> <caption><h1>Albums Details</h1></caption> <thead> <tr> <th>albumID</th> &

我一直试图显示我的数据库,但我就是无法让它工作。 谢谢你的帮助。我已经尝试了3个多小时,但一无所获

    <table>
        <caption><h1>Albums Details</h1></caption>
        <thead>
            <tr>
                <th>albumID</th>
                <th>Title</th>
                <th>Artist</th>
                <th>Country</th>
                <th>Company</th>
                <th>Price</th>
                <th>Year</th>
            </tr>
        </thead>
        <tbody>
            <?php 
HERE IS ERROR   while ($res = mysqli_fetch_array($query)) { //while loop....do this

                echo "<tr>";
                echo "<td>".$res['albumID']."</td>";
                echo "<td>".$res['title']."</td>";
                echo "<td>".$res['artist']."</td>";
                echo "<td>".$res['country']."</td>";
                echo "<td>".$res['company']."</td>";
                echo "<td>".$res['price']."</td>";
                echo "<td>".$res['year']."</td>";
                echo "</tr>";
            }
            ?>
代码如下:

    <table>
        <caption><h1>Albums Details</h1></caption>
        <thead>
            <tr>
                <th>albumID</th>
                <th>Title</th>
                <th>Artist</th>
                <th>Country</th>
                <th>Company</th>
                <th>Price</th>
                <th>Year</th>
            </tr>
        </thead>
        <tbody>
            <?php 
HERE IS ERROR   while ($res = mysqli_fetch_array($query)) { //while loop....do this

                echo "<tr>";
                echo "<td>".$res['albumID']."</td>";
                echo "<td>".$res['title']."</td>";
                echo "<td>".$res['artist']."</td>";
                echo "<td>".$res['country']."</td>";
                echo "<td>".$res['company']."</td>";
                echo "<td>".$res['price']."</td>";
                echo "<td>".$res['year']."</td>";
                echo "</tr>";
            }
            ?>

    <table>
        <caption><h1>Albums Details</h1></caption>
        <thead>
            <tr>
                <th>albumID</th>
                <th>Title</th>
                <th>Artist</th>
                <th>Country</th>
                <th>Company</th>
                <th>Price</th>
                <th>Year</th>
            </tr>
        </thead>
        <tbody>
            <?php 
HERE IS ERROR   while ($res = mysqli_fetch_array($query)) { //while loop....do this

                echo "<tr>";
                echo "<td>".$res['albumID']."</td>";
                echo "<td>".$res['title']."</td>";
                echo "<td>".$res['artist']."</td>";
                echo "<td>".$res['country']."</td>";
                echo "<td>".$res['company']."</td>";
                echo "<td>".$res['price']."</td>";
                echo "<td>".$res['year']."</td>";
                echo "</tr>";
            }
            ?>

相册详情
白蛋白
标题
艺术家
国家
单位
价格
年

您需要先执行查询,然后才能检索查询结果。

您在mysql查询后的$query中出错了吗?
    <table>
        <caption><h1>Albums Details</h1></caption>
        <thead>
            <tr>
                <th>albumID</th>
                <th>Title</th>
                <th>Artist</th>
                <th>Country</th>
                <th>Company</th>
                <th>Price</th>
                <th>Year</th>
            </tr>
        </thead>
        <tbody>
            <?php 
HERE IS ERROR   while ($res = mysqli_fetch_array($query)) { //while loop....do this

                echo "<tr>";
                echo "<td>".$res['albumID']."</td>";
                echo "<td>".$res['title']."</td>";
                echo "<td>".$res['artist']."</td>";
                echo "<td>".$res['country']."</td>";
                echo "<td>".$res['company']."</td>";
                echo "<td>".$res['price']."</td>";
                echo "<td>".$res['year']."</td>";
                echo "</tr>";
            }
            ?>