Mysqli Prepared Statements Error

人走茶凉 提交于 2019-12-11 03:29:19

问题


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 = ?

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

Then I pass them to call_user_func_array like bellow.

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

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"

Can anyone shed some light on me.


回答1:


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



来源:https://stackoverflow.com/questions/23290490/mysqli-prepared-statements-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!