Thanks guys.

I would do it like this:
PHP Code:$find_user = mysql_query("SELECT `name` FROM `players` WHERE `name` = '$username'");
if(mysql_num_rows($find_user) != 0) {
echo("$username is currenly unavailable");
} else {
echo("$username is available!");
}
Jack I was going todo it like that aswel, but I didn't want to really add extra lines of code. An ideal way todo it would be do it jacks way then do an ajax request when the field is changed, then display underneath is the username is available or not ^_^.
Technically by looking at them all, they should all work as you don't need an operator because the if statement checks if it's true automatically because from what I know.
is exactly likePHP Code:if (mysql_num_rows($query))
same goes with !mysql_num_rows() and == false.PHP Code:if (mysql_num_rows($query) == true)
Iszak, what I was trying to decipher on my post a page back is if:
would work the same asPHP Code:if (mysql_num_rows($query))
because I have always been lead to believePHP Code:if (mysql_num_rows($query) == 1 )
mean if the function was completed and returned without error (bad explanation).PHP Code:if (mysql_num_rows($query))
Well you'd expect it to be returned without error? I mean.. as long as the mysql_query executes correctly then there shouldn't be a problem with mysql_num_rows and yes those first two works exactly the same because 1 is also known as true, and == isn't a strict check so true, 0, 'true', etc are all executed as true. So by doing == 1 it's the same as == true.
Edit: There is one slight difference actually that I've noticed, if you return numerical values (with the exception of 0) in a function and use == true it seems to validate true, but if you use == 1, it will not validate true on numbers only alternative true syntax.
Last edited by Iszak; 14-02-2009 at 11:24 PM.
ugh, I was a bit drunk and doing other things, you disturbing me about PHP was the least on my mind.
Want to hide these adverts? Register an account for free!