douju2331 2014-03-17 09:04
浏览 26
已采纳

在php mysqli中结合普通查询和准备好的查询

I have used the following php mysqli database class PHP MYSqli class

In the below cases how can I use prepared statement

$qry =  " SELECT * FROM Master WHERE CustomerID = $customer_id ";
    $qry.= (!empty($type)) ? " and Type=? " : "";
    $qry.= (!empty($status)) ? " and Status=$status " : "";
    $qry.= (!empty($inline)) ? " and $inline " : "";
    $qry.= " ORDER BY JobID DESC ";
    $start =  !(empty($limit)) ? ($list_limit[$limit] * $page) : 0;
    $end =  !(empty($limit)) ? $list_limit[$limit]   : 20;
    $qry.= " LIMIT $start,$end ";
    //echo $qry;
    return $results = $db->rawQuery($qry,array($type));

While performing the above operation getting error as

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in /var/www/proj/lib/mydb.php on line 64
  • 写回答

1条回答 默认 最新

  • douru5373 2014-03-17 09:12
    关注

    Your problem is that number of variables doesn't match number of parameters in prepared statement. They must match.

    Also note that you shouldn't combine "normal" and prepared query. All your queries have to be prepared only.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大