dtng5978 2012-08-30 13:12
浏览 33

mysql_fetch_array()期望参数1是资源,布尔给定PHP [重复]

hello guys i am new here and i am having a hard time in analyzing this code. an error keeps on showing and i dont know what to do.

mysql_fetch_array() expects parameter 1 to be resource, boolean given

this happens everytime i use the search. any ideas?

    if(isset($_POST['search']))//if search
    {   
        if(($_POST['year']) && ($_POST['month']) && ($_POST['day']))
        $_SESSION['select']= mysql_query("SELECT * FROM ".$_SESSION['dbtable3']." WHERE eyear = '".$_POST['year']."' AND emonth = '".$_POST['month']."' AND edate = '".$_POST['day']."' ;" or die(mysql_error()));

        else if(($_POST['year']) && ($_POST['month']))
        $_SESSION['select']=mysql_query("SELECT * FROM ".$_SESSION['dbtable3']." WHERE eyear = '".$_POST['year']."' AND emonth = '".$_POST['month']."' ;" or die(mysql_error()));

        else if(isset($_POST['year']))
        $_SESSION['select']= mysql_query("SELECT * FROM ".$_SESSION['dbtable3']." WHERE eyear = '".$_POST['year']."' ;" or die(mysql_error()));

        else if(!$_POST['year'])
        die("FILL IN AT LEAST THE YEAR");

        else
        die("Date not found"); 


        if($_POST['year'])
            while($select2 = mysql_fetch_array($_SESSION['select']))
            {
                $n1 = $select2[0];
                $n2 = $select2[1];
                $n3 = $select2[2]."-".$select2[3]."-".$select2[4];

                echo
                "<tr>
                <td width=\"30px\"> $n1</td>
                <td width=\"30px\"> $n2</td>
                <td width=\"30px\"> $n3</td>
                </tr>";
            }
</div>
  • 写回答

4条回答 默认 最新

  • dongtanghuan1885 2012-08-30 13:14
    关注

    Each of your mysql_query() lines is wrong. You should close the parentheses before adding or die().

    This would be why you're getting a boolean instead of dieing with the error.

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献