0
我想準備一個mysql腳本,它首先根據給定的電子郵件檢查用戶的id,然後在下一個查詢中使用這個找到的id。我所做的,到目前爲止如下:調用未定義的方法mysqli_stmt :: free()
$find_id = "SELECT id from client
WHERE email = ? ";
$statement = $mysqli->prepare($find_id);
$statement->bind_param("s", $client_mail);
$statement->execute();
$statement->bind_result($id);
$statement->free();
$sql = "SELECT client_name, contact_name from client_addr
WHERE client_id = ? AND is_actual < ? ";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("is", $id, "Y");
$stmt->execute();
$result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
echo json_encode($result);
,但現在我得到有關該行的錯誤:
$statement->free();
,說Call to undefined method mysqli_stmt::free() in
。 然而,當我刪除此行,我發現了錯誤:
Uncaught exception 'mysqli_sql_exception' with message 'Commands out of sync; you can't run this command now'
在這條線:
$stmt = $mysqli->prepare($sql);
我怎樣才能解決呢?