jeudi 29 octobre 2015

Why am I getting this error? How can I fix?

I am getting the error "mysql_fetch_assoc() expects parameter 1 to be resource" I believe I am missing something, but I don't know what it could be. If I remove the "mysql_fetch_assoc" I get a similar error. I am new to PHP.

if ($username) {
    if ($_POST['submit']) {
        $oldpassword = $_POST['oldpassword'];
        $newpassword = $_POST['newpassword'];
        $repeatnewpassword = $_POST['repeatnewpassword'];

        $connect = mysqli_connect("localhost", "root", "Nflfan40", "phplogin"); 
        mysqli_select_db($connect, "phplogin");

        $queryget = ("SELECT password FROM users WHERE username = '$username'") or die("Error: Unregistered user.");
        $row = mysql_fetch_assoc($queryget);

        $oldpassworddb = $row['password'];

        if ($oldpassword==$oldpassworddb)
        {
            if ($newpassword==$repeatnewpassword) {
                echo "yay!";
            }
            else
                die("Error: New passwords don't match.");
        }
        else
            die("Error: Wrong initial password.");
    }
}
else
    die("Error: Must be logged in.");

What does this mean and how can this be resolved?

Aucun commentaire:

Enregistrer un commentaire