Results 1 to 10 of 10

Thread: PHP Help

  1. #1
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default PHP Help

    Hi,

    Please tell me what you think will happen if I run:

    PHP Code:
    function sesid()
                {
                    for(
    $i=0$i++; $i<8)
                    {
                    
    $num rand(1,9);
                    
    $sesid .= $num;
                    }
                }
                
                
    sesid(); 
    I know what SHOULD happen but I don't think it's working.

    Thanks.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  2. #2
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Quote Originally Posted by iUnknown View Post
    Hi,

    Please tell me what you think will happen if I run:

    PHP Code:
    function sesid()
                {
                    for(
    $i=0$i++; $i<8)
                    {
                    
    $num rand(1,9);
                    
    $sesid .= $num;
                    }
                }
     
                
    sesid(); 
    I know what SHOULD happen but I don't think it's working.

    Thanks.

    Cant see anything wrong with it. I ran it and i get a number between 1 and 9. so it works
    Back for a while

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    function sesid(  )
    {

        for( 
    $i 0$i 8$i++ )
        {
        
            
    $num rand1,);
            
    $sesid .= $num;
            
        }
        
        return 
    $sesid;

    }

    $id sesid(  ); 
    Last edited by Invent; 31-08-2008 at 08:02 PM.

  4. #4
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Quote Originally Posted by KnownSinner View Post
    Cant see anything wrong with it. I ran it and i get a number between 1 and 9. so it works
    You're supposed to get an 8 digit number haha.

    Quote Originally Posted by Invent View Post
    PHP Code:
    function sesid(  )
    {

        for( 
    $i 0$i 8$i++ )
        {
        
            
    $num rand1,);
            
    $sesid .= $num;
            
        }
        
        return 
    $sesid;

    }

    $id sesid(  ); 
    Works like a charm, thanks very much. +rep
    Last edited by iUnknown; 31-08-2008 at 08:45 PM.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


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

    Latest Awards:

    Default

    If you're trying to get an eight digit number why not do-

    rand( "10000000", "99999999" );
    Lets set the stage on fire, and hollywood will be jealous.

  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    If you're trying to get an eight digit number why not do-

    rand( "10000000", "99999999" );
    That'd be the better method.

  7. #7
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    PHP Code:
    function sesid(  )
    {

        for( 
    $i 0$i 8$i++ )
        {
        
            
    $num rand1,);
            
    $sesid .= $num;
            
        }
        
        return 
    $sesid;

    }

    $id sesid(  ); 
    Ah well as long as it works it's fine. Like the wires at the back of my computer, messy, but works great
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  8. #8
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    For loops are a lot slower than Toms method. Your logic is... interesting.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  9. #9
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Haha fine, I'll test it and use it.

    PHP Code:
    $id rand"10000000""99999999" ); 
    $sesid $id
    works like a charm would +rep Tom but gotta spread.
    Last edited by iUnknown; 31-08-2008 at 10:56 PM.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  10. #10
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Tom743 View Post
    If you're trying to get an eight digit number why not do-

    rand( "10000000", "99999999" );
    Why are you using strings on a number randomiser?


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

Posting Permissions

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