Re: multi-dimensional array

From: Date: Thu, 09 May 2002 21:28:07 +0000
Subject: Re: multi-dimensional array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96874@lists.php.net to get a copy of this message
You can't set an array subscript using an array; it should be a numerical value or a string. What you want to do is $division[$div_id] = $array; Better yet, try: $divison[$div_id] = mysql_fetch_array($result, MYSQL_ASSOC); J Steve Buehler wrote: > I am trying to learn some new things in the hopes that it would help me > with my mysql/PHP programming. The following code gives me an error: " > Warning: Illegal offset type in z.php on line 25 ". > > $result=mysql_query("SELECT * FROM division"); > while(($row=mysql_fetch_object($result))){ > $div_id=$row->div_id; > $array=array("sub1" => $row->sub1, > "sub1d" => $row->sub1d, > "sub2" => $row->sub2, > "sub2d" => $row->sub2d, > "sub3" => $row->sub3, > "sub3d" => $row->sub3d, > "sub4" => $row->sub4, > "sub4d" => $row->sub4d, > "sub5" => $row->sub5, > "sub5d" => $row->sub5d, > "game_length" => $row->game_length); > // The following is the line 25 > $division[$div_id][$array]=array(); > } > > What I am trying to do is to be able to later call > $division[$div_id][sub5] > etc... I sure hope that this can be done. If not, I will just have to > stick with temporary tables. > > Thanks > Steve

« previous php.general (#96874) next »