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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.