bobocheez Posted February 16, 2011 Share Posted February 16, 2011 Hey, I'm trying to check if a username is unique, but for some reason none of the methods that I've looked up seem to work. I'm aiming for the code to check if a username is unique, and if get the user to input the name again. $get = "SELECT `i` FROM `m` WHERE `i`=\"$r\""; $checkResults = mysql_query($getRandomness); while(mysql_num_row($checkResults) > 0) { //some code... //check again $get = "SELECT `i` FROM `m` WHERE `i`=$r"; $checkResults = mysql_query($get); } The error comes from the while line, but it comes up during the first check because the record is empty. This is the error: "Fatal error: Call to undefined function mysql_num_row()" Quote Link to comment Share on other sites More sharing options...
Sleeper Posted February 16, 2011 Share Posted February 16, 2011 Heres the version I use for usename and password if (!isset($user) || !isset($pass)|| empty($user) || empty($pass)) {header( "Location: $loc/login.php" );} else{ $result=mysql_query("select * from admin where username='$user' AND password='$pass'"); $rowCheck = mysql_num_rows($result); if($rowCheck > 0){ while($row = mysql_fetch_array($result)){ session_start(); $_SESSION['user'] = $_POST['username']; $_SESSION['time'] = $time;} header( "Location: adminindex.php" ); }else { header( "Location: $loc/login.php?action=invalid" );} } Looks like yours just doesn't know what to do if its empty first. 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.