[PHP] [] operator not supported for strings

2003-06-27 Thread Andrew McCombe
Hi

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'];
 $rst3 = sql_call(SELECT * FROM tmenu WHERE parent=.$r['id']);
 
 while ($a=mysql_fetch_array($rst3)) {
  $level2[$i][] = $a['name']; // giving error here
 }
 
}



[/code]


Regards
Andrew McCombe
Interactive Web Solutions (Stafford)
Tel: 01785 279921



-
The contents of this e-mail and any attachments are confidential and may
be legally privileged. If you have received this e-mail and you are not
a named addressee, please inform us as soon as possible on
+44 (0) 1785 279920  and then delete the e-mail from your system. If you are
not a named addressee you must not copy, use, disclose, distribute,
print or rely on this e-mail. Any views expressed in this e-mail or any
attachments may not necessarily reflect those of Interactive Web Solutions' management.
Although we routinely screen for viruses, addressees should scan this
e-mail and any attachments for viruses. Interactive Web Solutions makes no 
representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that for the protection of our business, we may monitor and
read e-mails sent to and from our server(s).

RE: [PHP] [] operator not supported for strings

2003-06-27 Thread Ford, Mike [LSS]
 -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