Jump to content

mysql_num_rows() error - SOLVED - SOLUTION INSIDE


Avalanche

Recommended Posts

Hello. I\'m having a problem with my script.

 

This is the part that I\'m having the error at:

[php:1:7e732ad053] function makeRandomPassword() {

/*****************************/
/* */
/* Random Password Script */
/* Made By phpfreak */
/* */
/*****************************/

$salt = \"abchefghjkmnpqrstuvwxyz0123456789\";
srand((double)microtime()*1000000);
for ($i=0; $i <= 7; $i++) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
}
return $pass;
}

$RANDOM_key = makeRandomPassword();

$query_registercheckIV = mysql_query(\"SELECT * FROM $tbl_users WHERE key=\'$RANDOM_key\'\"); // set register check query IV
$number_matchammtIV = mysql_num_rows($query_registercheckIV) or die(mysql_error());; // count number of matches

if($number_matchammtIV > 0) { // check for duplicate keys
echo \"Sorry, an internal error has occurred. This is not your fault and it is nothing serious.
All that you must do is register again. Sorry for the inconvenience.<p>
<a href=\"register.php\">Click here to register again</a><br>\";
require(\"include/footer.php\"); // use footer file
exit();
}[/php:1:7e732ad053]
And here is the error I get:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/burnttoa/public_html/avalanche/bop/register.php on line 102

You have an error in your SQL syntax near \'key=\'p6jh8t26\'\' at line 1

$tbl_users has been defined, and \"key\" is a valid field in the table defined.

 

Help please?

 

Thanks.

Link to comment
Share on other sites

Okay, I figured it out.

 

Apparently it didn\'t like that I was asking about a field name \"key,\" so it was stubborn and kept giving me errors. I just changed the field from \"key\" to \"user_key\" and everything works perfectly.

 

All you need is a little bit of experimenting!

 

:wink:

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.