php - Generating a random number not working on live server -
this has baffled me several hours now. below code in question. works totally fine on local server when migrated live server, problem i'm seeing random number generated , stored int type (the same on local) isn't random @ all. of entries have exact same number (2147483647).
i don't know why works locally won't on live server. it's exact version of php. i've researched few hours , can't find thing.
i'm sure simple oversight , figured posting here, 1 of brilliant minded developers point out?
if($_server['request_method'] == 'post' && !empty($_post['submit'])) { date_default_timezone_set("america/new_york"); $first_name = ucwords(addslashes(strip_tags($_post['firstname']))); $last_name = ucwords(addslashes(strip_tags($_post['lastname']))); $age = addslashes(strip_tags($_post['age'])); $location = addslashes(strip_tags($_post['state'])); $description = addslashes(strip_tags($_post['desc'])); $date_added = date("y-m-d"); $aka = ucwords(addslashes(strip_tags($_post['aka']))); $offender_id = mt_rand(1, 99999999999); //offense pertinent $date_of_offense = addslashes(strip_tags($_post['date_of_offense'])); $offense = addslashes(strip_tags($_post['offense'])); $added_by = addslashes(strip_tags($_post['added_by'])); if(empty($aka)) { $aka='none known'; } if($first_name&&$last_name&&$age&&$location&&$description&&$date_of_offense&&$offense&&$added_by) { include('../includes/db_cred.php'); $sql = "insert offenders values ('', '0', '$offender_id', '$first_name', '$last_name', '$aka', '$age', '$location', '$description', 'na', 'na', 'na', '$added_by', '$date_added')";
you making following php call:
$offender_id = mt_rand(1, 99999999999);
however, maximum value mt_rand()
appears capable of accepting on server 2^32 = 2147483647, value keep seeing.
from php manual:
the size of integer platform-dependent, although maximum value of 2 billion usual value (that's 32 bits signed)