douchan4674 2013-09-04 01:47
浏览 60
已采纳

准备好的声明期望0个参数,1个给定..,使用php手册示例

I took this straight from php manual example -- it was almost identical to what I needed but I am still getting this error.

Can someone tell me what I am missing?

$stmt = $link->prepare("SELECT obitBody, Photo FROM tnObit WHERE obitID = ?");
if ($stmt->execute(array($_POST['obitID']))) {
  while ($row = $stmt->fetch()) {
    print_r($row);
  }
}

mysqli_stmt::execute() expects exactly 0 parameters, 1 given in

  • 写回答

1条回答 默认 最新

  • dougengqiu8031 2013-09-04 01:55
    关注

    execute (the object-based one, as opposed to the older less-favored variant) doesn't actually take any parameters.

    From your query and attempted parameters to execute, it looks like you're trying to pass the needed parameters as an array to the execute call. This is not how it's done.

    You need to bind variables to the ? markers in a separate call before calling execute.

    This question (once fixed with the accepted answer) shows the general process you need to follow:

    • create statement;
    • prepare statement;
    • bind parameters;
    • execute (with no parameters);
    • store result (if buffering);
    • bind result variables;
    • fetch (in loop, most likely);
    • close statement.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)