Avalanche Posted August 21, 2003 Share Posted August 21, 2003 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. Quote Link to comment https://forums.phpfreaks.com/topic/927-mysql_num_rows-error-solved-solution-inside/ Share on other sites More sharing options...
Avalanche Posted August 22, 2003 Author Share Posted August 22, 2003 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: Quote Link to comment https://forums.phpfreaks.com/topic/927-mysql_num_rows-error-solved-solution-inside/#findComment-3107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.