Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    srand? Fatal error: Call to undefined function 1352483998() line 31

    This code has worked for ages so am not sure what is wrong now.
    Line 31 is the srand line:

    Code:
    //function
    function generatePassword($length=6,$level=2){
    
       list($usec, $sec) = explode(' ', microtime());
       srand((float) $sec   ((float) $usec * 100000));
    
       $validchars[1] = "23456789abcdefghjkmnpqrstuvwxyz";
       $validchars[2] = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
       $validchars[3] = "23456789_!@#$%&*()-= /abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ_!@#$%&*()-= /";
    
       $password  = "";
       $counter   = 0;
    
       while ($counter < $length) {
         $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
    
         // All character must be different
         if (!strstr($password, $actChar)) {
            $password .= $actChar;
            $counter  ;
         }
       }
    
       return $password;
    
    }

  • #2
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I added a + and now the script times out on this line:

    while ($counter < $length) { $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
    Last edited by qwertyjjj; 11-09-2012 at 06:36 PM.

  • #3
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The error was my host's web editor saves the files and strips operators...at least strips the + operator from all code!!!!!

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    at least strips the + operator from all code!!!!!
    if used in GET/POST, + is the replacement for a space character. your host’s web editor is just missing the escaping of sent content (I guess this is done through AJAX, as a regular form submit would take care of that).
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,299
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by qwertyjjj View Post
    The error was my host's web editor saves the files and strips operators...at least strips the + operator from all code!!!!!
    So keep your dev files locally, edit in notepad++ and upload via FTP.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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