问题
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