Jump to content

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc


bargainbob

Recommended Posts

I'm trying to set up a password changing form for users on my website, but keep hitting an error around this part of the code...

 

            {

                    $chpwdcheck = "SELECT password FROM table WHERE password='$cpword' AND ID='$ID'";

        $chpwdres = mysql_query($chpwdcheck) or die("Current Password Checking Problem: " . mysql_error());

        $chpwdcheckrow = mysql_num_rows($chpwdcheckres);

 

            if ($usernamecheckrow > 0)

            {

   

                mysql_query("UPDATE table SET password='$npword' WHERE ID='$UID'") or die("Password Updating Problem: " . mysql_error());

                $message = "You have successfully updated your password. <a href='index.php'>Click here </a>to return to the home page.";

            }

else

{

$message = "You incorrectly entered your current password. Please <a href='chpwd.php'> try again</a>.";

 

I get the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in directory/etc on line 41

 

Any ideas anyone?

Ah I see that now, should be the following:

 

            {

                    $chpwdcheck = "SELECT password FROM table WHERE password='$cpword' AND ID='$ID'";

        $chpwdres = mysql_query($chpwdcheck) or die("Current Password Checking Problem: " . mysql_error());

        $chpwdcheckrow = mysql_num_rows($chpwdcheckres);

 

            if ($chpwdcheckrow > 0)

            {

   

                mysql_query("UPDATE table SET password='$npword' WHERE ID='$UID'") or die("Password Updating Problem: " . mysql_error());

                $message = "You have successfully updated your password. <a href='index.php'>Click here </a>to return to the home page.";

            }

        else

        {

            $message = "You incorrectly entered your current password. Please <a href='chpwd.php'> try again</a>.";

 

However, I still get the same error message. :/

No it's users. Didn't know if it was easier to read as just table? :P

 

 

            {

                    $chpwdcheck = "SELECT password FROM users WHERE password='$cpword' AND ID='$ID'";

        $chpwdres = mysql_query($chpwdcheck) or die("Current Password Checking Problem: " . mysql_error());

        $chpwdcheckrow = mysql_num_rows($chpwdcheckres);

 

            if ($chpwdcheckrow > 0)

            {

   

                mysql_query("UPDATE users SET password='$npword' WHERE ID='$UID'") or die("Password Updating Problem: " . mysql_error());

                $message = "You have successfully updated your password. <a href='index.php'>Click here </a>to return to the home page.";

            }

        else

        {

            $message = "You incorrectly entered your current password. Please <a href='chpwd.php'> try again</a>.";

Ah I see it now! Sorry about the confusion!

 

 

        $chpwdres = mysql_query($chpwdcheck) or die("Current Password Checking Problem: " . mysql_error());

        $chpwdcheckrow = mysql_num_rows($chpwdcheckres);

 

Should in fact read:

 

        $chpwdcheckres = mysql_query($chpwdcheck) or die("Current Password Checking Problem: " . mysql_error());

        $chpwdcheckrow = mysql_num_rows($chpwdcheckres);

Thank you for your help!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.