php finding an existing data from mysql : <p>I am trying to create a registration page and throw an error when the username or the email exists but it doesn't catch the error. 
The table name in the database is 'users', username is 'uname' and email is 'email'. 
It inserts the data without a problem.
I am using the same array to catch if any field is empty, also they are working perfectly fine.</p>

<pre><code>        $query_usr = mysql_query("SELECT * FROM users WHERE uname='$uname' OR email='$email'");
                if ($query_usr["uname"] === $uname) {
          array_push($errors, "Username already exists");
        }
        if ($query_usr["email"] === $email) {
          array_push($errors, "email already exists");
        }
    if (count($err) == 0) {
            $pass = md5($pass1);
            $query = "INSERT INTO users (uname, email, password) VALUES('$uname', '$email', '$pass')";
            mysqli_query($connection, $query);

            $_SESSION["uname"] = $uname;
            $_SESSION["success"] = "You are now logged in";
            //header('location: index.php');
    }
    else{
        foreach ($err as $er){
            echo $er;
            echo "&lt;p&gt; &lt;/p&gt;";
        }
    }
</code></pre>
