marklarah Posted March 2, 2008 Share Posted March 2, 2008 <?php include_once 'top.php'; if ($_POST['u1'] == $_POST['u2'] && $_POST['e1'] == $_POST['e2'] && $_POST['p1'] == $_POST['p2']) { if ($_POST['u1'] == ''){ echo "No."; exit; } if ($_POST['e1'] == ''){ echo "No."; exit; } if ($_POST['p1'] == ''){ echo "No."; exit; } $sql = "select * from users where username='" . $_POST['u1'] . "'"; $result = mysql_query($sql); $sql2 = "select * from users where email='" . $_POST['e1'] . "'"; $result2 = mysql_query($sql2); if (mysql_num_rows($result) >= 1) { $err = "Username, "; }else{ $err = ""; } if (mysql_num_rows($result2) >= 1) { $err2 = "Email "; } else { $err2 = ""; } if (mysql_num_rows($result) >= 1 || mysql_num_rows($result2) >= 1) { echo '<b>Error: </b>'; echo $err; echo $err2; echo 'already in use - <a href="register.php">try again</a>.'; } else { $username = $_POST['u1']; $pass = md5($_POST['p1']); $email = $_POST['e1']; $usernamee = htmlentities($username); $emaile = htmlentities($email); $sql = "INSERT INTO users (ID, username, password) VALUES (NULL, '$usernamee', '$pass')"; mysql_query($sql) or die('Registration failed'); ?> You successfully registered. Now proceeding to login. <meta http-equiv="REFRESH" content="3;url=experiment login.php"> <?php } }else{ echo '<b>Error:</b> You filled the form in incorrectly - <a href="register.php">try again</a>.'; } ?> When registering: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/disturbe/public_html/reging.php on line 39 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/disturbe/public_html/reging.php on line 47 You successfully registered. Now proceeding to login. Can anyone help? Link to comment https://forums.phpfreaks.com/topic/93924-num-rows/ Share on other sites More sharing options...
pocobueno1388 Posted March 2, 2008 Share Posted March 2, 2008 It means one of your queries is failing, add die errors to the end of them, like this: $result = mysql_query($sql)or die(mysql_error()); Do that to both of them and see if you get an error. Link to comment https://forums.phpfreaks.com/topic/93924-num-rows/#findComment-481260 Share on other sites More sharing options...
choskins102 Posted March 2, 2008 Share Posted March 2, 2008 I am not the greatest person with mysql, but it looks like your mysql_num_results is returning a 0 count. Meaning, its not finding any results. I would add something that would tell the server what to do in the event that no results are found. It looks like when someone tries to register, it verifies that the username and email are not in use. If it find none, it returns a result of 0 which is causing your error. Also, adding the die function will halt the program from continuing on. Here is one way that you might be able to work around it: if (mysql_num_rows($result) >= 1) { die("That username is already in use."); } This won't completely fix the problem, but it should give you a general direction. Link to comment https://forums.phpfreaks.com/topic/93924-num-rows/#findComment-481264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.