I'm just having a strange prepare statement failed which I donno why
function send_notification($notification_member_ID,$notification_activity_type,$notification_parent_ID,$notification_parent_type){
global $mysqli;
$stmt = $mysqli->prepare("INSERT INTO notifications (`notification_member_ID`, `notification_activity_type`, `notification_parent_ID`, `notification_parent_type`) VALUES ( ? , ? , ? , ? )");
$stmt->bind_param('iiii', $notification_member_ID, $notification_activity_type, $notification_parent_ID, $notification_parent_type);
if($stmt->execute()){
return 1;
}else{
error_log("!send_notification(mysqli,$notification_member_ID,$notification_activity_type,$notification_parent_ID,$notification_parent_type) at ".date("Y-m-d H:i:s",time())."\n", 3, "{$dir_error_log}/transaction.log");
}
}
this is my debug attempt which failed
$product_ID=2;
$stmt = $mysqli->prepare("SELECT product_holder_ID FROM market where product_ID=? ");
$stmt->bind_param('i', $product_ID);
$stmt->execute();
$stmt->bind_result($product_holder_ID);
while($stmt->fetch()){
$mysql->send_notification($product_holder_ID,'1',$product_ID,'1');
}
Fatal error: Call to a member function bind_param() on a non-object
while I succeed if I move it out of the loop
$product_ID=2;
$stmt = $mysqli->prepare("SELECT product_holder_ID FROM market where product_ID=? ");
$stmt->bind_param('i', $product_ID);
$stmt->execute();
$stmt->bind_result($product_holder_ID);
while($stmt->fetch()){
}
$mysql->send_notification($product_holder_ID,'1',$product_ID,'1');
whats the black box inside that make it goes error in the first attempt?
More information:
$mysqli- error : Commands out of sync; you can't run this command now