I made a code to verify that the user and email are already exist, but when the user exists it returns the following error:
Fatal error: Fatal error: Can not use object of type stdClass as array
$query_check_user_name = $this->db->prepare('SELECT username, mail FROM users WHERE username= :user_name OR
mail = :user_email');
$query_check_user_name->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$query_check_user_name->bindValue(':user_email', $user_email, PDO::PARAM_STR);
$query_check_user_name->execute();
$result = $query_check_user_name->fetchAll();
if (count($result) > 0) {
for ($i = 0; $i < count($result); $i++) {
$this->errors[] = ($result[$i]['user_name'] == $user_name) ? MESSAGE_USERNAME_EXISTS : MESSAGE_EMAIL_ALREADY_EXISTS;
}
} else {
}