jaku78 Posted April 1, 2007 Share Posted April 1, 2007 I'm having trouble with this user verify script I made. And I know it's the SQL getting confused, whether it is the variable set-up I don't know. This is just a included file, and in the index file, it's already connected to the database, and there is no errors with that because the error is: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /dir/userver.inc on line 11 count unavailable And count unavailable is apart of one of my SQL function error messages. <?php //User Name Verify function userver($userveri) { $query = "SELECT 'username' FROM 'users' WHERE 'username'='$userveri'"; $sql = mysql_query($query); $nrows = mysql_num_rows($sql) or die("count unavailable"); if($nrows != 0) { echo "The username you have chosen already exists!"; die(); } else { return($userveri); } } ?> Help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/45147-solved-my-sql-num_row-help/ Share on other sites More sharing options...
Waldir Posted April 2, 2007 Share Posted April 2, 2007 <?php //User Name Verify function userver ( $userveri ) { $query = "SELECT username FROM users WHERE username = '$userveri'"; $sql = mysql_query($query); if(mysql_num_rows($sql) > 0) { echo "The username you have chosen already exists!"; die(); } else { return $userveri; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/45147-solved-my-sql-num_row-help/#findComment-219496 Share on other sites More sharing options...
jaku78 Posted April 2, 2007 Author Share Posted April 2, 2007 Thanks, I just tweaked the IF statement to say =! instead of > and it works! Thanks alot Waldir. Quote Link to comment https://forums.phpfreaks.com/topic/45147-solved-my-sql-num_row-help/#findComment-219512 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.