0

奇妙な準備ステートメントが失敗しただけですが、理由はわかりません

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");
  }
}

これは失敗した私のデバッグの試みです

$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');
}

致命的なエラー: オブジェクト以外でのメンバー関数 bind_param() の呼び出し

ループの外に移動すると成功しますが、

$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');

最初の試行でエラーになる内部のブラックボックスは何ですか?


詳しくは:

$mysqli- エラー : コマンドが同期していません。現在、このコマンドを実行することはできません

4

0 に答える 0