uneeb uneeb - 1 year ago 60
PHP Question

mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in

i am using a prepared statement i have passed exactly the same amount of variable in bind_param as i am expecting but still it is ginving me an error of variable count doesn't match.here's the code

$query="select `shipping_name`,`shipping_address1`,`shipping_address12`,`shipping_city`,`shipping_state`,`shipping_postalcode`,`billing_name`,`billing_address2`,`billing_address22`,`billing_city`,`billing_state`,`billing_postalcode` from puppy_shipping where unique_id=?";
$stmt = $db->prepare($query);
while ($stmt->fetch())

Answer Source

Your problem is with this line

$stmt->bind_result($bind, $shipping_name,$shipping_address1,$shipping_address12, ....);

You're trying to bind the variable-types, like you do with bind_param(), which is wrong - because this function does not have a parameter like that. bind_result()s only arguments are the values you select from the query, nothing else.

The solution is to simply remove $bind from your bind_result() call, making it

$stmt->bind_result($shipping_name, $shipping_address1, $shipping_address12, ....);


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download