Results 1 to 6 of 6
  1. #1

    Default [PHP]Random Password Generator..

    Having some trouble generating the random pass, Anyone have any ideas?
    PHP Code:
    <?php
    function random_pass($length)
    {
        
    $chars "abcdefghijkmnopqrstuvwxyz1234567890";
        
    $pass "";
        
    $charlength strlen($chars);
        
    $randchar rand()%($charlength);
        while(
    0<$length)
        {
            
    $pass substr($chars$randchar1);
        }
        return(
    $pass);
    }
    $password random_pass(7);
    echo(
    "" $password "");
    ?>
    That's just a prototype to test the function.
    It's basically meant to loop through until there are 7 characters in the pass string but it keeps giving the error:
    Code:
    Fatal error: Maximum execution time of 30 seconds exceeded in /home/jclabz/public_html/pass.php on line 10
    and
    Code:
    Fatal error: Maximum execution time of 30 seconds exceeded in /home/jclabz/public_html/pass.php on line 8
    Been trying to debug it for about an hour starting to annoy me alot now.

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

    Latest Awards:

    Default

    Sounds like it's taking too long to create the 7 chars, you could just make a class
    How could this hapen to meeeeeeeeeeeeeee?lol.

  3. #3
    Join Date
    Jul 2005
    Posts
    1,653
    Tokens
    50

    Latest Awards:

    Default

    set_timeout_limit(0);

  4. #4

    Default

    Quote Originally Posted by RYANNNNN View Post
    set_timeout_limit(0);
    You mean set_time_limit?
    That doesn't do anything cept change the timeout from 30 to 0?

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

    Latest Awards:

    Default

    PHP Code:
    <?php
    function random_pass($length)
    {
        
    $chars "abcdefghijkmnopqrstuvwxyz1234567890";
        
    $pass "";
        
    $charlength strlen($chars);
       
    $i=0;
        while(
    $i<$length)
        {
    $randchar rand()%($charlength);
            
    $pass substr($chars$randchar1);
    $i++;
        }
        return(
    $pass);
    }
    $password random_pass(7);
    echo(
    "" $password "");
    ?>

  6. #6

    Default

    Quote Originally Posted by Baving View Post
    PHP Code:
    <?php
    function random_pass($length)
    {
        
    $chars "abcdefghijkmnopqrstuvwxyz1234567890";
        
    $pass "";
        
    $charlength strlen($chars);
       
    $i=0;
        while(
    $i<$length)
        {
    $randchar rand()%($charlength);
            
    $pass substr($chars$randchar1);
    $i++;
        }
        return(
    $pass);
    }
    $password random_pass(7);
    echo(
    "" $password "");
    ?>
    Genius haha I think it was the incrementer that was needed for it to function properly :] i had to add a . on $pass .=""; so it would add to it rather than replace it but cheers for sorting that out for me :]

Posting Permissions

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