Search the Community
Showing results for tags 'random string'.
-
Thank you for taking the time to help me. I am trying to generate a string of sixteen characters that can look like 0000000000000000 to 9999999999999999 and set it as the global variable of $User_ID Here is the part of the code I am having trouble with: function genRandomString() { global $User_ID; $length = 16; $characters = "0123456789"; for ($p = 0; $p < $length; $p++) { $User_ID .= $characters[mt_rand(0, strlen($characters))]; } } Here is my whole code: <?php $con = mysql_connect("localhost","******","******"); if (!$con){ die('Could not connect: . mysql_error()'); } mysql_select_db("******", $con); echo "Connected to: " . $con; $eMail="$_POST[eMail]";$User_ID=""; echo "<br>My eMail: " . $eMail; $eMailResult = mysql_query("SELECT * FROM eMail WHERE eMail='$eMail'"); if (mysql_num_rows($eMailResult) == 0){ echo "<br>eMail is Unique"; } else { echo "eMail is NOT Unique<br>";} function genRandomString() { global $User_ID; $length = 16; $characters = "0123456789"; for ($p = 0; $p < $length; $p++) { $User_ID .= $characters[mt_rand(0, strlen($characters))]; } } echo "<br>User ID: " . $User_ID; mysql_close($con); ?>
- 3 replies
-
- random string
- global variable
-
(and 3 more)
Tagged with: