weixin_43824222
嘴角微上扬
采纳率100%
2018-12-03 15:09 阅读 1.9k

PHP中提示:Warning: mysqli_fetch_array().....应该怎么修改,万分感谢

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in.....
其中 $info = mysqli_fetch_array($sql);为出错的行
代码如下:

            <table width="180"  border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="5"></td>
              </tr>
              <?php
     $sql= mysqli_query($link,"SELECT * FROM `tb_gonggao` ORDER BY time desc limit 0,5");
             //按时间顺序查询最新的五条数据

        ********    $info = mysqli_fetch_array($sql);********
        if($info==false){
              ?>
              <tr>
                <td height="20" align="center">暂无新闻公告!</td>
              </tr>
              <?php 
                       }
         else{
         do{
              ?>
              <tr>
                <td height="20"><div align="center">
                  <table width="180"  border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="16" height="5"><div align="center"><img src="file:///D|/XAMPP/htdocs/shop/images/circle.gif" width="11" height="12"></div></td>
                      <td width="164" height="24"><div align="left"> <a href="gonggao.php?id=<?php echo $info['id'];?>">
                          <?php 
             echo substr($info['title'],0,25);
             if(strlen($info['title'])>25){
            echo "...";
              } 
          ?>
                      </a> </div></td>
                    </tr>
                  </table> 
                  </div></td>
              </tr>
              <?php
         }
           while($info=mysqli_fetch_assoc($sql));
         }//调出新闻标题
    ?>
          </table>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐