多次查询后PHP stmt prepare失败

多次查询后PHP stmt prepare失败,php,mysqli,prepared-statement,Php,Mysqli,Prepared Statement,警告:mysqli_stmt_bind_param()要求参数1为mysqli_stmt,第64行给出布尔值 我已经找到了很多其他关于这个问题的帖子,但是我尝试过的解决方案没有起到任何作用。 像stmt\u close()或stmt\u free()这样的事情没有什么区别 下面是我的实际代码片段: 第一,准备并执行: // Connect to database $mysqliID = mysqli_connect($mysqliHost, $mysqliUsername, $mysqliPas

警告:mysqli_stmt_bind_param()要求参数1为mysqli_stmt,第64行给出布尔值

我已经找到了很多其他关于这个问题的帖子,但是我尝试过的解决方案没有起到任何作用。 像
stmt\u close()
stmt\u free()
这样的事情没有什么区别

下面是我的实际代码片段:

第一,准备并执行:

// Connect to database
$mysqliID = mysqli_connect($mysqliHost, $mysqliUsername, $mysqliPassword);
if (!$mysqliID) throw new Exception("");
if (!mysqli_select_db($mysqliID, $mysqliDB)) throw new Exception("");

// Check if the username or email address aren't already accupied.
$stmt = mysqli_prepare($mysqliID, "SELECT id FROM Account WHERE username=? OR email=?");
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
$duplicates = 0;
mysqli_stmt_bind_result($stmt, $duplicateid);
while (mysqli_stmt_fetch($stmt))
{
    die ("error:-gebruikersnaam of email al in gebruik.");
}
// Save account with salted and hashed password.
include "PasswordHash.php";
$hashResult = create_hash($password);
$hashResultSplitted = explode(":", $hashResult);

$salt = $hashResultSplitted[2];
$hash = $hashResultSplitted[3];
$verified = 0;
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Account (username, hash, salt, email, verified) VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, "ssssi", $username, $hash, $salt, $email, $verified);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
// Save verification token.
$token = bin2hex(random_bytes(16));
$expirationtime = time() + (15 * 60);
$accountid = mysqli_insert_id($mysqliID);
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Verifications (token, expirationtime, accountid) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, "sii", $token, $expirationtime, $accountid);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
第二,准备并执行:

// Connect to database
$mysqliID = mysqli_connect($mysqliHost, $mysqliUsername, $mysqliPassword);
if (!$mysqliID) throw new Exception("");
if (!mysqli_select_db($mysqliID, $mysqliDB)) throw new Exception("");

// Check if the username or email address aren't already accupied.
$stmt = mysqli_prepare($mysqliID, "SELECT id FROM Account WHERE username=? OR email=?");
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
$duplicates = 0;
mysqli_stmt_bind_result($stmt, $duplicateid);
while (mysqli_stmt_fetch($stmt))
{
    die ("error:-gebruikersnaam of email al in gebruik.");
}
// Save account with salted and hashed password.
include "PasswordHash.php";
$hashResult = create_hash($password);
$hashResultSplitted = explode(":", $hashResult);

$salt = $hashResultSplitted[2];
$hash = $hashResultSplitted[3];
$verified = 0;
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Account (username, hash, salt, email, verified) VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, "ssssi", $username, $hash, $salt, $email, $verified);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
// Save verification token.
$token = bin2hex(random_bytes(16));
$expirationtime = time() + (15 * 60);
$accountid = mysqli_insert_id($mysqliID);
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Verifications (token, expirationtime, accountid) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, "sii", $token, $expirationtime, $accountid);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
第三次也是最后一次准备和执行:

// Connect to database
$mysqliID = mysqli_connect($mysqliHost, $mysqliUsername, $mysqliPassword);
if (!$mysqliID) throw new Exception("");
if (!mysqli_select_db($mysqliID, $mysqliDB)) throw new Exception("");

// Check if the username or email address aren't already accupied.
$stmt = mysqli_prepare($mysqliID, "SELECT id FROM Account WHERE username=? OR email=?");
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
$duplicates = 0;
mysqli_stmt_bind_result($stmt, $duplicateid);
while (mysqli_stmt_fetch($stmt))
{
    die ("error:-gebruikersnaam of email al in gebruik.");
}
// Save account with salted and hashed password.
include "PasswordHash.php";
$hashResult = create_hash($password);
$hashResultSplitted = explode(":", $hashResult);

$salt = $hashResultSplitted[2];
$hash = $hashResultSplitted[3];
$verified = 0;
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Account (username, hash, salt, email, verified) VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, "ssssi", $username, $hash, $salt, $email, $verified);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
// Save verification token.
$token = bin2hex(random_bytes(16));
$expirationtime = time() + (15 * 60);
$accountid = mysqli_insert_id($mysqliID);
$stmt = mysqli_prepare($mysqliID, "INSERT INTO Verifications (token, expirationtime, accountid) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, "sii", $token, $expirationtime, $accountid);
if (!mysqli_stmt_execute($stmt)) throw new Exception("");
因此,在第三段也是最后一段代码中,我在mysqli_prepare上得到了警告,但前两段都成功地完成了


解决方案:
原来名为Verifications的表应该是Verifications。通过良好的阅读和睡眠后的护理发现。

你应该检查一下,我试过了。但是因为mysqli_prepare返回一个布尔值。mysqli_stmt_error()不接受我的$stmt。因为它必须是mysqli_stmt对象。>警告:mysqli_stmt_error()要求参数1为mysqli_stmt,第58mysqli_prepare()行中给出的布尔值返回一条语句
object
FALSE
,如果发生错误。如果收到布尔值,则准备失败。