Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Re: Random Numbers not showing HELP!


Message #1 by Empier4552@a... on Thu, 19 Jul 2001 11:13:07 EDT
I think you meant for this:
$pinnumber = randomString;

...to be this:

$pinnumber = randomString();

HTH,

B.Page


> Heres the problem for an upcoming RPG which will be based on 
> PHP we're 
> making a bank and such and will be relying on randomly generated 5 
> digit #s..now i've gotten a script and done a simple echo of 
> the value 
> in the PIN Box for the form but it doesnt show..below is the script 
> 
> <?
> # return a randomly-generated string with input length
> # Blake Caldwell <blake@p...>
> function randomString($length=5){
>     static $srand;
>     if($srand != true){
>         $srand = true;
>         srand((double)microtime()*1000000);     # only seed once!
>     }
>     $chars = "1234567890";
>     for($i=0; $i<$length; $i++){
>         $pin .= substr($chars,rand(0,strlen($chars)-1),1);
>     }
>     
> return $pin;
> }
> 
> $pinnumber = randomString;
> ?>
> 
> <html>
> <head>
> <title>Add a character account</title>
> </head>
> <tr>
>     <td>Character PIN#</td>
> 
>     <td><b><input type="text" name="pin" value="<? echo 
> "$pinnumber"; ?>"></b></td> </tr>
> 
> (i've obviously cut out most of the HTML for people to read it)..i've 
> tried putting just $pin and taking out the $pinnumber = randomString 
> as well but neither seem to work is there something im forgetting to 
> do to execute the function?
> 

  Return to Index