From: joshua dot montgomery at middlebrow dot com Operating system: Debian PHP version: 4.3.8 PHP Bug Type: Scripting Engine problem Bug description: Array Memory Allocation Error With register_globals set to "On"
Description: ------------ We fixed this bug by setting Register_Globals to "Off", but we were also making other changes on the server to solve it, so that might not have been the fix. We are using the following code to store database entries in memory for use later on in the page When allocating memory for an array dynamically using a sql_query the values came out as strings, rather than arrays. I took all of the error checking out of the code below to make it more clear. We use this code to dump an array to a select menu creation function. It should be noted that this bug doesn't always appear, but seems to be produced for larger arrays (10 - 25) rather than arrays containing 2 or 3 entries. It should also be noted that adding the statement "$ArrayVariable = array()" before the following code also solves the problem. Reproduce code: --------------- $rslt = mysql_query("SQL....") $i = 0; while ($row = mysql_fetch_array($rslt)) { $ArrayVariable[$i]['Value'] = $row['SQL_Text Value']; $ArrayVariable[$i]['Label'] = $row['SQL_Text Label']; $i++; } print_r($ArrayVariable); Expected result: ---------------- Array ( [0] => Array ( [Value] => 145 [Label] => Adair, Kris ) [1] => Array ( [Value] => 20 [Label] => Bailey, Wayne ) [2] => Array ( [Value] => 22 [Label] => Bartos, Alan ) [3] => Array ( [Value] => 24 [Label] => Beatty, Marsha ) ) Actual result: -------------- Array ( [0] => 1A [1] => 2B [2] => 2B [3] => 2B ) -- Edit bug report at http://bugs.php.net/?id=29932&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29932&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29932&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29932&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=29932&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29932&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29932&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29932&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29932&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29932&r=support Expected behavior: http://bugs.php.net/fix.php?id=29932&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29932&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29932&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29932&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29932&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29932&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29932&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29932&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29932&r=float