plznty Posted June 20, 2009 Share Posted June 20, 2009 if ( $_GET['view'] == 'process' ) { // Gathered Information $Zuser = $_POST['user']; $pass = $_POST['pass']; $cash = $_POST['cash']; $Zquestion = $_POST['question']; $Zanswer = $_POST['answer']; // Lowercase gathered information $user = strtolower($Zuser); $question = strtolower($Zquestion); $answer = strtolower($Zanswer); // Check whether $user exists or not $sql = "SELECT * FROM `users` WHERE `username` = '$user'"; $rs = mysql_query($sql) or die(mysql_error()); // If number of rows returned is more than 1, it means username is duplicated if ( mysql_num_rows($rs) > 1 ) { echo "Duplicate username!"; } else { mysql_query("INSERT INTO users (username, password, money, current, rank, secretquestion, secretanswer) VALUES('$user', '$pass', '$cash', '0', 'noob', '$question','$answer' ) ") or die(mysql_error()); echo "User Created!"; } } It doesnt ever say "Duplicate username" when there is already a user in the sql table. It only works with user created. Otherwise if there is a duplicate it shows "Duplicate entry '' for key 2" Link to comment https://forums.phpfreaks.com/topic/163065-solved-problems-with-outputs/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2009 Share Posted June 20, 2009 if ( mysql_num_rows($rs) > 1 ) { That's because you are testing if there is more than one row from the SELECT query. If a user name already exists there would be one row, not more than one row. Link to comment https://forums.phpfreaks.com/topic/163065-solved-problems-with-outputs/#findComment-860418 Share on other sites More sharing options...
plznty Posted June 20, 2009 Author Share Posted June 20, 2009 I was looking at that earlier. Thanks ! Link to comment https://forums.phpfreaks.com/topic/163065-solved-problems-with-outputs/#findComment-860420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.