mysqli prepared statements UPDATE throwing error message
Moderators: egami, macek, gesf
Try to rearrange the code like this:
Code: Select all
$stmt->execute();
$x = call_user_func_array(array($stmt, 'bind_result'), &$bindParams);
if (false === $x) {die('bind_param()error :' . $mysqli->error);}
$stmt->close();
The other thing that you can try is to change:
to
Make a direct call using bind_result instead of using call_user_func()
Code: Select all
$x = call_user_func_array(array($stmt, 'bind_result'), &$bindParams);
Code: Select all
$stmt->bind_result(&$Address, &$Permit_Rate);
The problem is that there is actually missing one parameter.
The array containing your bind params needs to have the first element set to the type of the variables in question.
so: UPDATE customers set name=? where id=?
requires an array of three fields for putting to bind_params
a[0]='si';//for string and integer
a[1]=$newName;
a[2]=$customerID;
You don't have to worry bout the field-types and can set everything to string (='s') and the rest will be done automagically.
Easier: If you have 5 fields with params you just set:
a[0]=str_repeat('s',5);
The array containing your bind params needs to have the first element set to the type of the variables in question.
so: UPDATE customers set name=? where id=?
requires an array of three fields for putting to bind_params
a[0]='si';//for string and integer
a[1]=$newName;
a[2]=$customerID;
You don't have to worry bout the field-types and can set everything to string (='s') and the rest will be done automagically.
Easier: If you have 5 fields with params you just set:
a[0]=str_repeat('s',5);