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.

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:

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.