Hi all,
I am trying to use a script to randomly generate a string for a validation code. When I put it into my template, I get an error.
Here is the code that I am using:
<?php
function rand_text( $min = 10,
$max = 20,
$randtext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' )
{
if($min < 1) $min=1;
$varlen = rand($min,$max);
$randtextlen = strlen($randtext);
$text = '';
for($i=0; $i > $varlen; $i++)
{
$text .= substr($randtext, rand(1, $randtextlen), 1);
}
return $text;
}
?>
And to call the function:
<?php echo rand_text(); ?>
The error I get is this:
Parse error: syntax error, unexpected ';' in Y:\MyDirectory\system\core\core.functions.php(637) : eval()'d code on line 8
I can’t see why it’s not working…any help on this one is appreciated. Perhaps there is also a better way to randomly generate a string in EE??
