douhan5853 2013-12-06 11:43
浏览 90
已采纳

警告:mysql_fetch_assoc()期望参数1是资源,在[重复]中给出布尔值

I get this error every time I run the code, I tried going through other similar threads but it didn't help. I am newbie

        $count=3;
            $db = new mysqli ('localhost', 'root', '', 'test');

        $selectSQL='SELECT * FROM coll_mark WHERE univ="'.$_POST['univ'].'" AND '.$brachTxt.'<="'.$_POST['perc'].'"AND '.$brachTxt.'!=""  ORDER BY '.$brachTxt.' DESC LIMIT '.$count;       
        $queryset='';
        $queryset=mysql_query($selectSQL);
        while($row = mysql_fetch_assoc($queryset)) 
        {
        echo('<tr><td id="ColgNames">'.$row['name'].'</td><td align="center">'.$row[$brachTxt].'</td></tr>');
        }

I also checked whether the query structure is correct or not, but the query is working perfectly.

</div>
  • 写回答

4条回答 默认 最新

  • doudang1890 2013-12-06 11:58
    关注

    Try Like this,

    $count=3;
    $db=mysql_connect('localhost','root','');
    if(!$db) {
        die('Could not connect: '.mysql_error());
    }
    $connection_string=mysql_select_db('test',$db);
    $selectSQL='SELECT * FROM coll_mark WHERE univ="'.$_POST['univ'].'" AND '.$brachTxt.'<="'.$_POST['perc'].'"AND '.$brachTxt.'!="" ORDER BY '.$brachTxt.' DESC LIMIT '.$count;       
    $queryset=mysql_query($selectSQL);
    $num=mysql_num_rows($queryset);
    if(0==$num) {
        echo "No record";
        exit;
    } else {
        while($row=mysql_fetch_assoc($queryset)) {
            echo('<tr><td id="ColgNames">'.$row['name'].'</td><td align="center">'.$row[$brachTxt].'</td></tr>');
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮