> -----Original Message----- > From: Andrew McCombe [mailto:[EMAIL PROTECTED] > Sent: 27 June 2003 11:18 > > Can anyone tell me why i'm getting this error? > > Fatal error: [] operator not supported for strings in > c:\inetpub\wwwroot\Iweb-sites\Exp\menu2.php on line 41 > > [code]: > > > $rst2=sql_call("SELECT * FROM tmenu WHERE parent=".$r['id']); > // now have array of corporate, entertainment and identity > > for ($i=0; $i < mysql_num_rows($rst2); $i++) { > $r=mysql_fetch_array($rst2); > $level2[$i] = $r['name'];
$r['name'] will be a string -- and so, therefore, will $level2[$i] be. > $rst3 = sql_call("SELECT * FROM tmenu WHERE parent=".$r['id']); > > while ($a=mysql_fetch_array($rst3)) { > $level2[$i][] = $a['name']; // giving error here $level2[$i] is still a string, and the [] notation when applied to a string selects an individual character -- but you haven't specified which character, so this is an error. Did you mean the first assignment to $level2[$i] to start a new array that you later add to in the loop? In which case you might want to do $level2[$i] = array($r['name']); If you meant something else, you probably need to tell us exactly what it is you're trying to do, so we can suggest accurate solutions. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php