检查局部变量是否等于局部变量的正确方法

时间:2016-05-05 19:01:05

标签: php function mysqli syntax local-variables

这不会评估,即使值应该相等,它也会直接进入else事件。表列名称与数据库匹配,因此......

我是否需要某种类型的报价($ recruitcheck == $ recruitpass)?

$recruiter = $_POST["recruiter"];
$recruitpass = $_POST["recruitpass"];
$recruitcheck = mysqli_query($maindb, "select aurapass from auras where auraname='$recruiter'");
if($recruitcheck == $recruitpass) {
    $badgecheck = mysqli_query($maindb, "select recruitbadge from auras where auraname='$recruiter'");
    if($badgecheck == "0") {
        echo "<script>alert('Recruiter information correct, but there is no recruit badge.')</script>";
        exit();
    } else {
        echo "<script>alert('Recruiter badge accepted.')</script>";
        $emailcheck = mysqli_query($maindb, "select * from auras where email='$email'");
        $namecheck = mysqli_query($maindb, "select * from auras where auraname='$auraname'");
        if(mysqli_num_rows($emailcheck) > 0 || mysqli_num_rows($namecheck) > 0){
            echo "<script>alert('New auraname/email is already taken.')</script>";
            exit();
        } else {
            exit();                        
        }
    }
} else {
    echo "<script>alert('Aura information of recruiter is incorrect. Please, use preexisting aura information to confirm recruiter identity.')</script>";
    exit();
}

1 个答案:

答案 0 :(得分:0)

$ recruitpass是一个字符串,而$ recruitcheck是 mysqli_result 对象。在将对象与$ recruitpass

进行比较之前,您需要在对象中获取字符串值