'Warning: Undefined property: PDOStatement::$rowCount

private function checkUsernameExist($username){
    $stmt=$this->pdo->prepare("SELECT username FROM users WHERE username=:username");
    $stmt->bindParam(":username", $username,PDO::PARAM_STR);
    $stmt->execute();
    $count=$stmt->rowCount();
    if($count >0){
        return true;
    }else{
        return false;
    }
}
private function validateEmail($em){
    $stmt=$this->pdo->prepare("SELECT email FROM users WHERE email=:email");
    $stmt->bindParam(":email",$em,PDO::PARAM_STR);
    $stmt->execute();
    if($stmt->rowCount !=0){
        array_push($this->errorArray,Constants::$emailTaken);

    }
    if(!filter_var($em,FILTER_VALIDATE_EMAIL)){
        array_push($this->errorArray,Constants::$emailInvalid);
        return ;

    }
}
php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source