ID: 40187
User updated by: callawey at gmail dot com
Reported By: callawey at gmail dot com
Status: Bogus
Bug Type: Math related
Operating System: windows xp
PHP Version: 5.2.0
New Comment:
while($row = $DB->fetchArray($result))
{
$str = "";
for($i=0;$i<=12;$i++)
{
$str .= rand(0,9);
}
$sqlc = sprintf("UPDATE %s SET user_id='%s' WHERE
id='%s'",
$DB->prefix("users"), $str, $row["id"]);
$DB->queryF($sqlc);
}
this returns same number everytime even i use $str = ""; in every loop
Why ?
Previous Comments:
------------------------------------------------------------------------
[2007-01-21 19:12:02] callawey at gmail dot com
while($row = $DB->fetchArray($result))
{
for($i=0;$i<=12;$i++)
{
$str .= rand(0,9);
}
//$str = mt_rand(100000000000, 999999999999);
$sqlc = sprintf("UPDATE %s SET user_id='%s' WHERE
id='%s'",
$DB->prefix("users"), $str, $row["id"]);
$DB->queryF($sqlc);
}
this code makes all colums -1
------------------------------------------------------------------------
[2007-01-21 19:10:58] [EMAIL PROTECTED]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
Integer overflow on 32 bit systems is the cause.
------------------------------------------------------------------------
[2007-01-21 19:06:47] callawey at gmail dot com
Description:
------------
rand and mt_rand generates random lenght integer between -9999999999
and +9999999999.
example mt_rand(100000000000, 999999999999);
outputs: -564, -688852, 5586666988, -68889558
Reproduce code:
---------------
$str = mt_rand(100000000000, 999999999999);
Expected result:
----------------
positive numbers between 100000000000 and 999999999999
Actual result:
--------------
-492911349,1162038978,-219333642
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40187&edit=1