我有一個致命的錯誤在我的代碼,致命錯誤:調用一個成員函數準備()一個非對象在...上線28的mysqli - 致命錯誤
更新代碼:
<?
function check($sql, $db, $email, $pwdHasher, $hash, $userExists, $sendPass) {
if(!empty($_POST['email']) && validateEmail($email)) {
$email = $_POST["email"];
if ($sql = $db->prepare("select email from users where email=?")) {
$sql->bind_param('s', $email);
$sql->execute();
$sql->bind_result($email);
while ($sql->fetch()) {
$pwdHasher = new PasswordHash(8, FALSE);
$hash = $pwdHasher->HashPassword($userExists["email"]);
$sendPass=$hash;
($sql = $db->prepare('insert into password_reset (code) values (?)')); Warning: mysqli::prepare() [mysqli.prepare]: All data must be fetched before a new statement prepare takes place
$sql->bind_param('s', $hash); //Fatal error: Call to a member function bind_param() on a non-object
$sql->execute();
$sql->fetch();
}
}
}
}
if (check($sql, $db, $email, $email,$pwdHasher, $hash, $userExists, $sendPass)) {
($sql = $db->prepare("select userid from password_reset where code=?"));
$sql->bind_param('s', $hash);
$sql->execute();
$sql->bind_result($hash);
if ($sql->fetch()) {
echo $hash;
};
$pwrurl = "www.yoursite.com/reset_password.php?userid=" .$hash . "&code =" . $sendPass;
$mailbody = "Dear user,<br><br>If this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website www.yoursitehere.com<br>
To reset your password, please click the link below. If you cannot click it, please paste it into your web browser's address bar.<br> <a href='$pwrurl'>$pwrurl</a> <br> <br>
Thanks,\nThe Administration";
$mail->MsgHTML($mailbody);
$mail->AddAddress($email,"Membro");
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Deu erro: " . $mail->ErrorInfo;
} else {
echo "Enviado com sucesso";
}
$sql->close();
$db->close();
}
?>
有人可以檢查代碼嗎?我的想法是。我有一個功能,如果有效發送電子郵件。可能我在代碼中有一些錯誤
謝謝!!
您是否在同一時間出現PHP致命錯誤**和** SQL錯誤? – 2011-03-21 15:52:23
$ db是與數據庫的連接 – 2011-03-21 15:53:48