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?

Link to comment
Share on other sites

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. :/

Link to comment
Share on other sites

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>.";

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.