RE: [PHP] HTML lists & PHP

2002-01-30 Thread Ford, Mike [LSS]

> -Original Message-
> From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]]
> Sent: 28 January 2002 22:02
> 
> I keep getting parse error with this code:
> ($teams[] is a big array that I got by using mysql_fetch_array)
>  
>  
>$r = "game";
>echo "";
>echo "$teams[$r.'1']";
>echo "$teams[$r.'16']";
>echo "";

This really is a faq: if you want to substitute anything other than a simple variable 
name into a double-quoted string, you MUST use curly braces {} to delimit it. So:

echo "${teams[$r.'1']}";

is what you need.

(Note: I also treat variable names including underlines _ as being not simple, as I've 
had cases where PHP seems to parse these incorrectly -- for example, 
"...$long_name..." is treated as "...${long}_name...", not "...${long_name}...".)

If you have any doubts, include the {} -- even for simple variables, it does no harm 
to write, for example "...${var}...".

I do sometimes wonder whether the {} should be made mandatory in some future version, 
even for simple variables, to avoid exactly this kind of confusion.

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, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HTML lists & PHP

2002-01-28 Thread hugh danaher

Try
$teams[${"r1"."1"}]
or a variation on this theme
hugh


- Original Message - 
From: "Edward van Bilderbeek - Bean IT" <[EMAIL PROTECTED]>
To: "Phil Schwarzmann" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, January 28, 2002 2:16 PM
Subject: Re: [PHP] HTML lists & PHP


> maybe you can try something like this... 
> 
> $r1 = "game1"
> $r2 = "game16";
> 
>   echo "";
>   echo "$teams[$r1]";
>   echo "$teams[$r2]";
>   echo "";
> 
> Greets,
> Edward
> 
> 
> 
> > I keep getting parse error with this code:
> > ($teams[] is a big array that I got by using mysql_fetch_array)
> >  
> >  
> >$r = "game";
> >echo "";
> >echo "$teams[$r.'1']";
> >echo "$teams[$r.'16']";
> >echo "";
> >  
> > Im trying to make a dropdown list.
> >  
> > Here is the error message:
> > Parse error: parse error, expecting `']'' in
> > /home/filanya/www/madness/bracket.php on line 65
> > 
> > (line 65 is the third line down)
> >  
> > THANKS
> > 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HTML lists & PHP

2002-01-28 Thread Edward van Bilderbeek - Bean IT

maybe you can try something like this... 

$r1 = "game1"
$r2 = "game16";

  echo "";
  echo "$teams[$r1]";
  echo "$teams[$r2]";
  echo "";

Greets,
Edward



> I keep getting parse error with this code:
> ($teams[] is a big array that I got by using mysql_fetch_array)
>  
>  
>$r = "game";
>echo "";
>echo "$teams[$r.'1']";
>echo "$teams[$r.'16']";
>echo "";
>  
> Im trying to make a dropdown list.
>  
> Here is the error message:
> Parse error: parse error, expecting `']'' in
> /home/filanya/www/madness/bracket.php on line 65
> 
> (line 65 is the third line down)
>  
> THANKS
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]