mySQLi调试问题

时间:2013-09-24 12:52:29

标签: php mysqli

我实际上有这个PHP代码,我用它来获取我的数据库信息..

function searchUserEmail($username, $raw_email){
    //Prepare Statements
    $query = "SELECT * FROM users WHERE username = ?";
    $query2 = "SELECT * FROM users WHERE email = ?";
    //Sanitize Input
    $user = $this->conn->real_escape_string($username);
    $email = $this->conn->real_escape_string($raw_email);

    if($stmt = $this->conn->prepare($query)){
        $stmt->bind_param('s', $user);
        $stmt->execute();
        if($stmt->num_rows > 0){
            $stmt->close();
            return true;
        }
    }

    if($stmt = $this->conn->prepare($query2)){
        $stmt->bind_param('s', $email);
        $stmt->execute();
        if($stmt->num_rows > 0){
                $stmt->close();
        return true;
        }
    }
    return false;
}

我已经尝试了很多次,通过语句检查程序运行它,但它仍然不起作用。有什么我想念的吗?

不知怎的,它总是返回false(即使它假设返回true)

1 个答案:

答案 0 :(得分:-1)

mysql_select_db($数据名,$ conn);在