...

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



qwertyjjj
11-09-2012, 07:01 PM
This code has worked for ages so am not sure what is wrong now.
Line 31 is the srand line:



//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, 07: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, 07: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, 12:15 PM
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, 11:54 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum