Bug #17290 Updated: Cannot use [] for reading

From: Date: Wed, 26 Jun 2002 18:09:48 +0000
Subject: Bug #17290 Updated: Cannot use [] for reading
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12143@lists.php.net to get a copy of this message
 ID:               17290
 Updated by:       robjohnwilson@hotmail.com
 Reported By:      mellow@mellow.dk
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      4.1.2
 New Comment:

I seem to be getting this error also in 4.2.1 running on SunOS - is
this possible?


Previous Comments:
------------------------------------------------------------------------

[2002-05-24 06:08:26] witterstein@web.de

I occured a similar error when using (also on lx-machine)

while ($db->next_record())
{
/* Fix for php 4.2.1 */
	$foo=$db->f('RIS_VSR_FK');
	$curstate[$foo] = $db->f('RIS_ALLOWED');
/* End Fix
	$curmain[$db->f('RIS_VSR_FK')] = $db->f('RIS_ISMAIN');
<-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
	$defmainvs = $db->f('RIS_ISMAIN') == 'YES' ?
$db->f('RIS_VSR_FK') :
$defmainvs;
}

Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ']'
in xxx on line 166 <-!!!!!!!!!!!! this line

That means that accessing an object in a class instance and using this
as the arrays index also does not work, using a simple variable does
work.

Probably there is a major bug in the parser (priority?), because the
workaround with $array[{$array_b[1][2]}], which I would expect that
first {$array_b[1][2]} is evaluated and then $array[$evaluation_result]
gets the error that no {} are allowed. I am not sure this is a new bug,
but I remember in 4.0.x it always worked fine.

------------------------------------------------------------------------

[2002-05-17 11:02:29] mellow@mellow.dk

I've build an array using the following in a function :

-------------
$this->get_data(array("","","and D.XiParentId=
'gwak_root_element'
ORDER BY D.vcOrder"));
        $arrCategory = $this->return_array();
        for($i = 0 ; $i < sizeof($arrCategory) ; $i++) {
            $this->get_data(array("","","and D.XiParentId = '"
.
$arrCategory[$i]["XiDataId"] . "' ORDER BY D.vcOrder"));
            $arrItem[$arrCategory[$i]["vcItemId"]] =
$this->return_array();
        }
return $arrItem;
-------------

This constructs an array with values like :
$arrItem["project_priority"][0] = array(...)
$arrItem["project_priority"][1] = array(...)
etc...

Later I tried to do the following to the returned $arrItem :
-------------
$arrItem["project_severity"][] = array("XiDataId" =>
"gwak_get_all",
"vcText" => "All");
-------------

This gives the error :
-------------
Fatal error: Cannot use [] for reading in
/home/plb/public_html/gwak/module/project/include/Task.class.php on
line 160
-------------

Funny because doing the following :
-------------
        $arrThis["here"][] = array("XiDataId" => "asdasdas",
"vcText"
=> "324234234");
        $arrThis["here"][] = array("XiDataId" => "asdasdas",
"vcText"
=> "324234234");
        $arrThis["here"][] = array("tr" => "ert");
        $arrThis["where"][] = array("er" => "ert");
        $arrThis["where"][] = array("we" => "ert");
        $arrThis["where"][] = array("tr" => "ert");

-------------
gives no error at all, eventhough $arrThis and $arrItem have exactly
the same format. Do you guys have an idea what is going on here?

The only thing i can see could cause the problem is that $arrItem is
built using "arrays within arrays":
$arrItem[$arrCategory[$i]["vcItemId"]] = array(...);
Can this be the cause or...

In advance thx...


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=17290&edit=1



Thread (12 messages)

« previous php.bugs (#12143) next »