donglu9743 2014-03-20 01:38
浏览 12

mysql_fetch_array()期望参数1是资源,在...中给出布尔值[HELP] [重复]

// I'm just testing out to display data from database but i keep getting this error :( anyone help?

 <?php
        include 'Connect.php';
        ?>
        <?php
        //query the database
        $query = mysql_query("SELECT * FROM people ");
        mysql_select_db("roofandfacade");

        //fetch the results/convert results into array

        While ($rows= mysql_fetch_array($query)) {
            echo $rows['Person_Name'];
        }




        ?>
</div>
  • 写回答

1条回答 默认 最新

  • drgaeqdqiiyg14608 2014-03-20 01:40
    关注

    Looks like you are selecting your database after running your query. That won't work for what I hope is obvious reasons.

    $query = mysql_query("SELECT * FROM people ");
    mysql_select_db("roofandfacade");
    

    Reverse that:

    mysql_select_db("roofandfacade");
    $query = mysql_query("SELECT * FROM people ");
    

    I am not sure why you don't have mysql_select_db("roofandfacade"); in your connect.php file with your call to mysql_connect(). That would be a more logical place to put it.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题