Jump to content

genRandomString but nothing displays on echo


wright67uk

Recommended Posts

Im sure ive missed somthing from the code below!  I get no error codes, but nothing displays.  Just a frustrating blank white screen!  Any idea?  The eventual result im after is to generate a random 10 digit number to use as a customer ID number, for use within a confirmation link. I thought this would be stage 1.

 

<html><body><?php
function genRandomString() {
$length = 10;
$characters = ’0123456789abcdefghijklmnopqrstuvwxyz’;
$string = (”; ) //brackets put here to stop phpfreaks.com displaying numbers   
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];}
return $string;}
echo "$string";
?></body></html>

 

Many thanks.

Thankyou, i have managed to get the below code to generate a random number;

 

<html><body><?php
function genRandomString() {
$length = 10;
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$string = "";    
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
echo genRandomString();
?></body></html>

 

 

Do you know how I can now assign this random number to a variable.  i would like to be able to go;

 

 

<p>This is your random number; $random , thankyou</p>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.