Re: Coding Question: values from an array

From: Date: Sat, 29 Jul 2000 18:43:23 +0000
Subject: Re: Coding Question: values from an array
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1625@lists.php.net to get a copy of this message
> I'm querying a mysql database. I'm getting one row returned and putting it > into an array. I think want to display the contents of the array. > > I'm using the echo command to do it like this: > echo $mdisp['fname']; > > And this command works just find. > > But why when I do it like this: > echo "$disp['fname']"; > > do I get the error message: > Parse error: parse error, expecting T_STRING' or > T_VARIABLE' or > `T_NUM_STRING' in /u04/httpd/htdocs/new_hros_proc.php on line 21 > . > > > I guess maybe you can't echo a row in the array? Inside quoted strings you have to use curly braces if you wish to display something other than simple variables. In you case you would need to do: echo "${disp['fname']}"; However, I would suggest jumping out of your quoted string instead. ie. echo "blah blah". $disp['fname'] ."blah blah"; -Rasmus

« previous php.db (#1625) next »