Mysqli准备的语句错误 [英] Mysqli Prepared Statements Error

查看:55
本文介绍了Mysqli准备的语句错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点不喜欢第一次使用mysqli动态参数绑定. 我的查询是

I'm little bit confused with first use of mysqli dynamic parameter binding. My query is

 UPDATE tb_hotel SET hotel_name = ?, hotel_overview = ?, hotel_active = ?,
 hotel_location_description = ?, hotel_location_gmap = ?, hotel_cm_mapping_id = ?
 WHERE hotel_id = ?

当我转储传递给call_user_func_array的数组时,是

When I dump the array which I pass to call_user_func_array is

  array (size=8)
  0 => string 'ssisssi' (length=7)
  1 => &string 'sdfsfdsf' (length=8)
  2 => &string 'sdfdsf' (length=6)
  3 => &int 0
  4 => &string 'dsfdsfds' (length=8)
  5 => &string 'fsdfsdf' (length=7)
  6 => &string 'fsdfdsfsdf' (length=10)
  7 => &int 17

然后我像波纹管一样将它们传递给call_user_func_array.

Then I pass them to call_user_func_array like bellow.

call_user_func_array(array($stmt, 'bind_param'), $param_array_bind);

我收到错误消息警告:mysqli_stmt :: bind_param():类型定义字符串中的元素数量与其中的绑定变量数量不匹配"

I'm getting the error "Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in"

谁能向我阐明一下.

推荐答案

您要在MySQL代码中放入7个字段,并且数组中包含8个元素.这就是问题.

You're putting 7 fields in your MySQL code and your array has 8 elements. This is the problem.

这篇关于Mysqli准备的语句错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆