我是SQL和PHP的新手。我的目標很簡單:檢查數據庫中是否存在電子郵件地址。我正在使用以下代碼:Mysqli bind_result錯誤
$email = [email protected];
$conn = new mysqli("localhost", "root", "", "mysite"); // Create connection
if ($conn->connect_error) { // Check connection
die("Connection failed: " . $conn->connect_error);
}
$stmt = $conn->prepare("SELECT * FROM contacts WHERE email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$result = $stmt->num_rows;
echo $result;
每當我收到一個錯誤。它說我在bind_result中使用了錯誤的參數數量。它是如何的?
哦..我忘了。這是一條錯誤消息:bind_result():綁定變量的數量與預準備語句中的字段數不匹配 – Fusion