我错过了什么导致:命令不同步;你现在不能 运行 这个命令?

What am I missing that is causing: Commands out of sync; you can't run this command now?

$recruitcheck/$badgecheck 确实有效,它 return 是正确的,并且它提供了经过验证的回显,但我假设我对 store/bind/close 做了一些不正确的事情,因为我我在弄清楚它的工作原理时遇到了一些问题。

$emailcheck/$namecheck 出现了问题,因为它没有准确地 return 查询,并且它最终绕过了 $register 阶段,在那里它 return 了错误echo,所以 $emailcheck/$namecheck 总是 false/0.

我以前让它工作过,但我正在尝试实现一些安全功能,因此我添加了准备好的语句,在添加这些语句之前我几乎不知道我在做什么,所以如果这个问题不合适,我深表歉意,或者信息不够。如果您发表评论,我会编辑 post 使其更相关。请给我机会

$recruitcheck = mysqli_prepare($maindb, "SELECT aurapass, recruitbadge FROM auras WHERE auraname = ?");
            mysqli_stmt_bind_param($recruitcheck, "s", $recruitername);
            mysqli_stmt_execute($recruitcheck);
            mysqli_stmt_bind_result($recruitcheck, $passcheck, $badgecheck);
            mysqli_stmt_fetch($recruitcheck);
            if($passcheck == $recruitpass){
                if($badgecheck == "valid"){
                    mysqli_close($recruitcheck);
                    echo "<script>alert('Recruiter badge verified.')</script>";
                    $emailcheck = mysqli_prepare($maindb, "SELECT * FROM auras WHERE email = ?");
                    mysqli_stmt_bind_param($emailcheck, "s", $email);
                    mysqli_stmt_execute($emailcheck);
                    mysqli_stmt_fetch($emailcheck);
                    $namecheck = mysqli_prepare($maindb, "SELECT * FROM auras WHERE auraname = ?");
                    mysqli_stmt_bind_param($namecheck, "s", $auraname);
                    mysqli_stmt_execute($namecheck);
                    mysqli_stmt_fetch($namecheck);
                    if(mysqli_num_rows($emailcheck)>0 || mysqli_num_rows($namecheck)>0){
                        die("<script>alert('New auraname/email is already taken.')</script>");
                    }
                    else{
                        mysqli_close($emailcheck);
                        mysqli_close($namecheck);
                        if($email == $emailconfirm){
                            $register = mysqli_prepare($maindb, "INSERT INTO auras (recruitername, recruitmethod, email, birthday, country, gender, auraname) VALUES (?, ?, ?, ?, ?, ?, ?)");
                            mysqli_stmt_bind_param($register, "sssisss", $recruitername, $recruitmethod, $email, $birthday, $country, $gender, $auraname);
                            mysqli_stmt_execute($register);
                            mysqli_close($register);
                            if(!$register) {
                                echo mysqli_error($maindb);
                                die("<script>alert('Error returned during registration: See bottom of page.')</script>");
                            }
                            else{
                            die("<script>alert('New aura registered successfully!')</script>");

$passcheck/$badgecheck 只是简单的绑定变量,它们唯一被调用的地方就是你在这里看到它们的地方。否则:

$recruitpass = cleaninput($_POST["recruitpass"]);

function cleaninput($info) {
            $info = trim($info);
            $info = stripslashes($info);
            $info = htmlspecialchars($info);
            return $info;}

recruitcheck 确实有效,因为它会随着输入的错误与正确的变化而变化,但代码无法正确地继续进行下一次检查。

您先为 $emailcheck$namecheck 查询调用 mysqli_close(),然后再对它们调用 mysqli_num_rows()