doujiu5464 2017-01-13 02:31
浏览 46
已采纳

while循环在第一个循环停止,因为mysqli错误

the error reads

mysqli_fetch_array() expects parameter 1 to be mysqli_result, double given in C:\xampp\htdocs\beta\jawa\isi.php on line 744

line 744 is : while($r=mysqli_fetch_array($hasil))

the full code :

<?php
$cari = "SELECT * FROM produk WHERE " ;
for ($i=0; $i<=$jml_kata; $i++) {
    $cari .= "deskripsi LIKE '%$pisah_kata[$i]%' OR nama_produk LIKE '%$pisah_kata[$i]%'";
    if ($i < $jml_kata ) {
        $cari .= " OR "; 
    }
}

$cari .= " ORDER BY id_produk DESC LIMIT 12";
$hasil  = mysqli_query($con,$cari);

while($r=mysqli_fetch_array($hasil)) {

    include "diskon_stok.php";
    echo"<div class='container_produk'>
        <a href='produk-$r[id_produk]-$r[produk_seo].html'><img src='http://images.rajafotocopy.com/foto_produk/$r[gambar]'/></a>
        <div class='detail'> 
            <span style='font-family : sui'>$r[nama_produk]</span><br />
            $divharga
        </div>
    </div>";
}
?>

I don't understand what's wrong with mysqli_result....? it is returning the 1st loop but after that it throws an error and expects parameter 1 to be mysqli_result?

  • 写回答

2条回答 默认 最新

  • dongmen5867 2017-01-13 02:48
    关注

    Something in diskon_stok.php is doing:

    $hasil = <something>;
    

    where <something> is a number.

    So when the loop repeats and it calls mysqli_fetch_array($hasil), the variable no longer contains the query result, it contains this number, and that call fails.

    Change the name of the variable you're using for the query result.

    $result  = mysqli_query($con,$cari);
    
    while($r=mysqli_fetch_array($result)){
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致
  • ¥150 求 《小魔指》街机游戏机整合模拟软件