wright67uk Posted February 21, 2011 Share Posted February 21, 2011 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. Link to comment https://forums.phpfreaks.com/topic/228354-genrandomstring-but-nothing-displays-on-echo/ Share on other sites More sharing options...
Pikachu2000 Posted February 21, 2011 Share Posted February 21, 2011 You never call the function. Also, see here: return. The first paragraph will probably end up being particularly relevant to your question. Link to comment https://forums.phpfreaks.com/topic/228354-genrandomstring-but-nothing-displays-on-echo/#findComment-1177463 Share on other sites More sharing options...
wright67uk Posted February 21, 2011 Author Share Posted February 21, 2011 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> Link to comment https://forums.phpfreaks.com/topic/228354-genrandomstring-but-nothing-displays-on-echo/#findComment-1177883 Share on other sites More sharing options...
BlueSkyIS Posted February 21, 2011 Share Posted February 21, 2011 $something = genRandomString(); Link to comment https://forums.phpfreaks.com/topic/228354-genrandomstring-but-nothing-displays-on-echo/#findComment-1177885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.