php - why `mysqli->prepare` failed inside `while($stmt->fetch())` -
i'm having strange prepare statement failed donno why
function send_notification($notification_member_id,$notification_activity_type,$notification_parent_id,$notification_parent_type){ global $mysqli; $stmt = $mysqli->prepare("insert 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) @ ".date("y-m-d h:i:s",time())."\n", 3, "{$dir_error_log}/transaction.log"); } } this debug attempt failed
$product_id=2; $stmt = $mysqli->prepare("select product_holder_id market 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 member function bind_param() on non-object
while succeed if move out of loop
$product_id=2; $stmt = $mysqli->prepare("select product_holder_id market 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 black box inside make goes error in first attempt?
more information:
$mysqli- error : commands out of sync; can't run command now
Comments
Post a Comment