From:             andreyra at chtivo dot ru
Operating system: Windows 2003 Server
PHP version:      5.2.0
PHP Bug Type:     Arrays related
Bug description:  POST/GET Arrays won't initialize properly

Description:
------------
I have found strange behaviour with PHP POST/GET arrays. With print_r()
command I have see all contents of array, but if I trying to access to
values of array directly - I have got errors.

I have test this code with:
php5.1.2
php5.2.0
php5.2-win32-200702041530
Apache2.0.58/win32/php5apache2.dll
Apache2.2.3/win32/php5apache2_2.dll
Apache2.2.4/win32/php5apache2_2.dll

And always I have same results.

In my php.ini:
register_globals    =   On
register_long_arrays    =   On
register_argc_argv  =   On
post_max_size       =   512M


Reproduce code:
---------------
<form name="topics" method="post">
<input type="text" name="topic[1]['name']" value="Some text"><br/>
<button onclick="this.form.submit(true);">POST</button>
</form>
<?php
    if (!isset($_POST['topic'])){
      return false;
     };
    if (!is_array($_POST['topic'])){
      return false;
     };
    foreach ($_POST['topic'] as $topic_id=>$arr){
      print_r($arr);
      if (!isset($arr['name'])){
        echo "<br/>\r\nERROR! NAME field is not set!\r\n";
        continue;
       };
      echo 'OK.';
     };

?>

Expected result:
----------------
OK.

Actual result:
--------------
ERROR! NAME field is not set!

-- 
Edit bug report at http://bugs.php.net/?id=40354&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40354&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40354&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40354&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40354&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40354&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40354&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40354&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40354&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40354&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40354&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40354&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40354&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40354&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40354&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40354&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40354&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40354&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40354&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40354&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40354&r=mysqlcfg

Reply via email to