mysql - PHP caches RAND() variable values -
i have following code in file index.php:
include('db_connect.php'); //here's script provides mysql connection database $a = round(rand(1,100)); $b = round(rand(160,202)); $c = round(rand(50,110)); $d = round(rand(1,99999)); $sql = "insert sinstance (p1,p2,p3,p4) values ('".$a."','".$b."','".$c."','".$d."')"; $result = mysql_query($sql) or die(mysql_error());
obviously, randomly generates values , inserts them record myisam database table sinstance.
the problem: after ~1000 records generated & inserted, it's impossible generate new records (with unique sets of values). every new record clone of old 1 (with same p1-p2-p3-p4 values).
the question: how avoid , make php generate unique records?
the clue: server-side problem php, somehow caches values set of rand() function. problem not connected neither browser, nor mysql itself.
not sure if you're not doing wrong, reseting random seed generator trick :
Comments
Post a Comment