Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Thanks guys.
    Vouches
    [x][x]

  2. #12
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    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!");


  3. #13
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    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 ^_^.


    www.fragme.co = a project.

  4. #14

    Default

    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.
    PHP Code:
    if (mysql_num_rows($query)) 
    is exactly like
    PHP Code:
    if (mysql_num_rows($query) == true
    same goes with !mysql_num_rows() and == false.

  5. #15
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Iszak, what I was trying to decipher on my post a page back is if:

    PHP Code:
    if (mysql_num_rows($query)) 
    would work the same as

    PHP Code:
    if (mysql_num_rows($query) == 
    because I have always been lead to believe

    PHP Code:
    if (mysql_num_rows($query)) 
    mean if the function was completed and returned without error (bad explanation).


    www.fragme.co = a project.

  6. #16

    Default

    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.

  7. #17
    Join Date
    Feb 2009
    Posts
    131
    Tokens
    0

    Default

    Quote Originally Posted by Source View Post
    Yes blinger I believe that would be correct, my appologies I kind of rushed the response as no-one was really helping.

    Oh and calon, thanks for the wonderful block on msn considering how much I helped you. Your welcome.
    ugh, I was a bit drunk and doing other things, you disturbing me about PHP was the least on my mind.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •