Chuckster Posted August 12, 2010 Share Posted August 12, 2010 This is the wrong section. I know. Wont let me make a thread in support. When i try to register, im getting this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /***/***/public_html/GRPG/register.php on line 13 This is my register.php <? include 'nliheader.php'; if (isset($_POST['submit'])) { $username = strip_tags($_POST["newname"]); $signuptime = time(); $password = $_POST["newpass"]; $password2 = $_POST["newpassagain"]; $email = $_POST["email"]; $checkuser = mysql_query("SELECT * FROM `grpgusers` WHERE `username`='$username'"); $username_exist = mysql_num_rows($checkuser); if($username_exist > 0){ $message .= "<div>I'm sorry but the username you chose has already been taken. Please pick another one.</div>"; } if(strlen($username) < 4 or strlen($username) > 20){ $message .= "<div>The username you chose has " . strlen($username) . " characters. You need to have between 4 and 20 characters.</div>"; } if(strlen($password) < 4 or strlen($username) > 20){ $message .= "<div>The password you chose has " . strlen($password) . " characters. You need to have between 4 and 20 characters.</div>"; } if($password != $password2){ $message .= "<div>Your passwords don't match. Please try again.</div>"; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $message .= "<div>The e-mail address you entered was invalid.</div>"; } //insert the values if (!isset($message)){ $result= mysql_query("INSERT INTO `grpgusers` (ip, username, password, email, signuptime, lastactive)". "VALUES ('".$_SERVER['REMOTE_ADDR']."', '$username', '$password', '$email', '$signuptime', '$signuptime')"); echo Message('Your account has been created successfully! Redirecting to login page in 5 seconds. <meta http-equiv="refresh" content="5;url=login.php">'); if ($_POST['referer'] != ""){ $result= mysql_query("INSERT INTO `referrals` (`when`, `referrer`, `referred`)". "VALUES ('$signuptime', '".$_POST['referer']."', '".$username."')"); } die(); } } ?> <? if (isset($message)) { echo Message($message); } ?> <tr><td class="contenthead"> .: Register </td></tr> <tr><td class="contentcontent"> <table width='28%' border='0' align='center' cellpadding='0' cellspacing='0'> <form name='register' method='post' action='register.php'> <tr> <td height='26'><font size='2' face='verdana'>Username</font></td> <td><font size='2' face='verdana'> <input type='text' name='newname'> </font></td> </tr> <tr> <td height='28'><font size='2' face='verdana'>Password</font></td> <td><font size='2' face='verdana'> <input type='password' name='newpass'> </font></td> </tr> <tr> <td height='28'><font size='2' face='verdana'>Confirm Password</font></td> <td><font size='2' face='verdana'> <input type='password' name='newpassagain'> </font></td> </tr> <tr> <td height='26'><font size='2' face='verdana'>Email address</font></td> <td><font size='2' face='verdana'> <input type='text' name='email'> </font></td> </tr> <tr> <td></td> <td><font size='2' face='verdana'> <input type='hidden' name='referer' value='<? echo $_GET['referer'] ?>'> <input type='submit' name='submit' value='Register'> </font></td> </tr> </table> </form> <center> © 2007 MyNeoCorp Productions </center> </td></tr> <? include 'nlifooter.php'; ?> Wheres the problem there? ?( Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 Ohh, and i also removed that line, no longer getting that error, but nw it wont let me login. So i still think the register.php is fuked:( Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 $checkuser = mysql_query("SELECT * FROM `grpgusers` WHERE `username`='{$username}'"); Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 thats a replacment of line 11. Right? Well i replaced that, and still the same error. Isnt the error on line 13? Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 $checkuser = mysql_query('SELECT * FROM `grpgusers` WHERE `username` = "'.$username.'"'); if( mysql_num_rows($checkuser) != 0){ $message .= "<div>I'm sorry but the username you chose has already been taken. Please pick another one.</div>"; } Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 could you please tell me what lines to replace??? I have no isea were to place that code ;) Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 Lines 11 - 17 $checkuser = mysql_query("SELECT * FROM `grpgusers` WHERE `username`='$username'"); $username_exist = mysql_num_rows($checkuser); if($username_exist > 0){ $message .= "<div>I'm sorry but the username you chose has already been taken. Please pick another one.</div>"; } Replace with the code i pasted earlier (1 post back). Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 Thanks, but now thw error is : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/mafiakil/public_html/GRPG/register.php on line 12 :( Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 <? include 'nliheader.php'; if (isset($_POST['submit'])) { $username = strip_tags($_POST['newname']); $signuptime = time(); $password = $_POST['newpass']; $password2 = $_POST['newpassagain']; $email = $_POST['email']; $message = ''; $checkuser = mysql_query('SELECT * FROM `grpgusers` WHERE `username`="'.$username.'"'); if ( mysql_num_rows($checkuser) > 0 ){ $message .= "<div>I'm sorry but the username you chose has already been taken. Please pick another one.</div>"; } if ( strlen($username) < 4 or strlen($username) > 20 ){ $message .= "<div>The username you chose has " . strlen($username) . " characters. You need to have between 4 and 20 characters.</div>"; } if ( strlen($password) < 4 or strlen($username) > 20 ){ $message .= "<div>The password you chose has " . strlen($password) . " characters. You need to have between 4 and 20 characters.</div>"; } if ( $password != $password2 ){ $message .= "<div>Your passwords don't match. Please try again.</div>"; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { // ereg is deprecated $message .= "<div>The e-mail address you entered was invalid.</div>"; } //insert the values if ( !isset($message) ){ $result= mysql_query("INSERT INTO `grpgusers` (ip, username, password, email, signuptime, lastactive)". "VALUES ('".$_SERVER['REMOTE_ADDR']."', '$username', '$password', '$email', '$signuptime', '$signuptime')"); echo Message('Your account has been created successfully! Redirecting to login page in 5 seconds. <meta http-equiv="refresh" content="5;url=login.php">'); if ( $_POST['referer'] != "" ){ $result= mysql_query("INSERT INTO `referrals` (`when`, `referrer`, `referred`)". "VALUES ('$signuptime', '".$_POST['referer']."', '".$username."')"); } die(); } } ?> <? if ( isset($message) ) { echo Message($message); } ?> <tr><td class="contenthead"> .: Register </td></tr> <tr><td class="contentcontent"> <table width='28%' border='0' align='center' cellpadding='0' cellspacing='0'> <form name='register' method='post' action='register.php'> <tr> <td height='26'><font size='2' face='verdana'>Username</font></td> <td><font size='2' face='verdana'> <input type='text' name='newname'> </font></td> </tr> <tr> <td height='28'><font size='2' face='verdana'>Password</font></td> <td><font size='2' face='verdana'> <input type='password' name='newpass'> </font></td> </tr> <tr> <td height='28'><font size='2' face='verdana'>Confirm Password</font></td> <td><font size='2' face='verdana'> <input type='password' name='newpassagain'> </font></td> </tr> <tr> <td height='26'><font size='2' face='verdana'>Email address</font></td> <td><font size='2' face='verdana'> <input type='text' name='email'> </font></td> </tr> <tr> <td></td> <td><font size='2' face='verdana'> <input type='hidden' name='referer' value='<? echo $_GET['referer'] ?>'> <input type='submit' name='submit' value='Register'> </font></td> </tr> </table> </form> <center> © 2007 MyNeoCorp Productions </center> </td></tr> <? include 'nlifooter.php'; ?> Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /***/***/***/register.php on line 13 :s Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 Also, i think another problem is that when i make an account, its not inserting to the database. It says ive succecfully made an account, but there is still no users in the database... I think that problem may be coming from a different part of the code. Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 LOL can tell im not a user of GRPG, Ok maybe mysql_num_rows isn't actually in their class (that's if they use a class) i guess since you don't add the connection into the end they edit it somehow. May be best to have a quick look (i don't have the GRPG engine or i would). Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 hmm ok. But whats the deal with it not inserting a new user to the database? Quote Link to comment Share on other sites More sharing options...
Equinox Posted August 12, 2010 Share Posted August 12, 2010 Well, clearly they don't have a class - they have just created a connection to the database and are including it. So obviously mysql_num_rows() will exist. $checkuser = mysql_query('SELECT * FROM `grpgusers` WHERE `username`="'.$username.'"') or die(mysql_error()); See what happens now. It could be that 'username' doesn't exist. There are plenty of reasons why this may not work Anyway, paste back the error that is given by that line of code I just gave you. Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 Now im getting , No database selected XD In the dbconfig file the database and all that is DEFO correct. Quote Link to comment Share on other sites More sharing options...
Equinox Posted August 12, 2010 Share Posted August 12, 2010 Now im getting , No database selected XD In the dbconfig file the database and all that is DEFO correct. Well, if you're 100% sure that the connection is correct - it may be that your database user doesn't have all privileges. Check your MySql user has all privileges. If not, paste the connection file here (obviously edit out all of the important connection information) Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 User defo has all privs. <? $conn = mysql_connect("localhost","MY USERNAME","MY PASS"); $db = mysql_select_db("DATABASE NAME"); ?> Quote Link to comment Share on other sites More sharing options...
Equinox Posted August 12, 2010 Share Posted August 12, 2010 And inside 'nliheader.php' your database connection file is being included? Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 yes its included :/ Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted August 12, 2010 Share Posted August 12, 2010 ah good point EQ my bad Quote Link to comment Share on other sites More sharing options...
Chuckster Posted August 12, 2010 Author Share Posted August 12, 2010 So any other ideas??? Or could someone possibly post a working register.php? ?( 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.