Re: Completing form prompts from array - error!
| From: | Miles Thompson | Date: | Tue, 28 Nov 2000 23:46:57 +0000 |
| Subject: | Re: Completing form prompts from array - error! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27704@lists.php.net to get a copy of this message | ||
Michael,
That's it! I was beginnning to wonder if I'd have to convert all the array
elements to variables. I don't even need the single quotes around the element
name.
Thanks - Miles Thompson
Michael Geier wrote:
> You cannot define an array object from within a text str.
>
> Try:
>
> $user_form = "
> <form method=\"post\" action=\"$PHP_SELF\">
>
> <P> " . $arr_lbl[ 'lbl_cUsername' ] . "
> <input type=\"text\" name=\"$cUsername\" size=10></p>
> <P>Email ... and so on to the end of the form ...
> </form>";
>
> I used to be really frustrated by this too.
>
> -----Original Message-----
> From: Miles Thompson [mailto:milesthompson@sprint.ca]
> Sent: Tuesday, November 28, 2000 3:52 PM
> To: php-general@lists.php.net
> Subject: [PHP] Completing form prompts from array - error!
>
> I'm borrowing Julie Meloni's technique of defining a form and assigning it
> to a variable, but want to
> enhance it by providing the form prompts from an array. This will allow me
> to accomodate different
> languages.
>
> Here's a code fragment ...
>
> $user_form = "
> <form method=\"post\" action=\"$PHP_SELF\">
>
> <P> $arr_lbl[ lbl_cUsername ]
> <input type=\"text\" name=\"$cUsername\" size=10></p>
> <P>Email ... and so on to the end of the form ...
> </form>";
>
> The problem lies with --> $arr_lbl[ lbl_cUsername ] <-- which is returning
> this error:
> Parse error: parse error, expecting
T_STRING' or
> T_VARIABLE' or
> `T_NUM_STRING' in
> /usr/local/apache/htdocs/auction/user_register.php on line 122.
>
> I've also tried it with
> $arr_lbl[ \"lbl_cUsername\" ]
> $arr_lbl[ 'lbl_cUsername' ]
> .
> .
> .
> \"$arr_lbl[ lbl_cUsername ]\"
>
> All this is very puzzling, because just ahaed of the form the statement
> echo $arr_lbl[ lbl_cUsername ]
> works fine and prints out "Username".
>
> Any suggestions?
>
> TIA - Miles Thompson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net