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 4 of 5 FirstFirst 12345 LastLast
Results 31 to 40 of 45
  1. #31
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Or that.
    Hi, names James. I am a web developer.

  2. #32
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    Well, let's all just put down the one guy who's trying to make the Forum a little more interesting.... who cares if you reference the PHP website as a reference? A lot of the time the site can confuse instead of help so I think this thread is a great idea. Anyways...

    Today I'm going to talk about the rand() function.

    PHP Code:
    <?php
    // rand ( lowestDigit, highestDigit )
    echo rand(1,5); // Outputs any of these: 1 2 3 4 5
    ?>
    What this function does is generate a random integer between lowestDigit and highestDigit (note that it includes the lowestDigit and highestDigit in it's number range - basically it can return lowestDigit, highestDigit, and everything in between).

    I find this function very helpful when you're trying to generate random CAPTCHAs, License Keys/Key Codes, and anything else that requires random anything.

    Hope this helps someone out

  3. #33
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by PureG View Post
    if($x == 0) {
    // error
    } elseif($x > 0) {
    //succeed
    } else {
    // error
    }

    apposed to

    if($x == 0) {
    // fail
    } else {
    if($x > 0) {
    // succeed
    } else {
    // fail
    }
    }
    What ar you on about?

    I did this:

    Quote Originally Posted by Jackboy View Post
    PHP Code:
    <?PHP
    $knownSinner 
    mysql_query("SELECT * FROM `idiotlist` WHERE `username` = 'knownSinner'");
    $Howmany mysql_num_rows($knownSinner);
    if (
    $Howmany == '0'){
    print 
    "You are only lying to yourself...";
    }else{
    print 
    "Thats what i thought.";
    }
    ?>

  4. #34
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    So what happens if mysql_num_rows returns an error
    Hi, names James. I am a web developer.

  5. #35
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by PureG View Post
    So what happens if mysql_num_rows returns an error
    Why would it?

    $knownSinner is a valid resource.

  6. #36
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I meant if it did, "what happens if" it was to error?
    Hi, names James. I am a web developer.

  7. #37
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    Or you could just do
    if( $x >= 1 )
    {
    //success
    }
    else
    {
    //fail
    }
    or

    if( $x >= 1 )
    {
    echo ("You failed");
    }
    else
    {
    echo ("You failed again");
    }
    Lets set the stage on fire, and hollywood will be jealous.

  8. #38
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    you fail.

  9. #39
    Join Date
    Jun 2005
    Posts
    2,688
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by PureG View Post
    I meant if it did, "what happens if" it was to error?
    It would return the same error message doing it either as:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    or

    PHP Code:
     $result mysql_num_rows($query);
    if(
    $result==0) { } 
    mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.

    Personally I prefer to use:

    PHP Code:
     if(mysql_num_rows($result)==0) { } 
    It is just the same as putting it into a class and executing it:

    PHP Code:
     if($db->num_rows($query)==0) { } 
    However the proper way in which to return the amount of rows is by doing it in the SQL itself:

    select count(id) as total from tablename where 1=1

  10. #40
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Yea baving im not talkin about that, im talking about his method of doing it.
    Hi, names James. I am a web developer.

Page 4 of 5 FirstFirst 12345 LastLast

Posting Permissions

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