CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   srand? Fatal error: Call to undefined function 1352483998() line 31 (http://www.codingforums.com/showthread.php?t=281672)

qwertyjjj 11-09-2012 06:01 PM

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;

}


qwertyjjj 11-09-2012 06:30 PM

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

qwertyjjj 11-09-2012 06:47 PM

The error was my host's web editor saves the files and strips operators...at least strips the + operator from all code!!!!!

Dormilich 11-10-2012 11:15 AM

Quote:

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).

tangoforce 11-10-2012 10:54 PM

Quote:

Originally Posted by qwertyjjj (Post 1290437)
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.


All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.