Re: Help with Variable Variables in Array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks so much, Naintara, simplifying the field name in the way you
suggested seems to fix it.

Andrew

On 2/20/06, Naintara <naintara@xxxxxxxxxxxx> wrote:
> Hi,
>
> Firstly, if you are assigning the value of variable $myrow['article_title']
> to $right_row,
> you should print $right_row and not $$right_row
>
> Because, if say, $myrow['article_title'] contained value "article1",
> $$right_row would look for variable
> $article1, which probably doesn't exist, hence no value.
>
> You could also try creating your field name simpler, something like:
> $tmp_fldname = $type . "_title';
> $right_row = $myrow[$tmp_fldname];
>
> This should work, I haven't tested it.
>
> Naintara
>
> -----Original Message-----
> From: Andrew Darby [mailto:adarby@xxxxxxxxx]
> Sent: Monday, February 20, 2006 10:19 PM
> To: php-db@xxxxxxxxxxxxx
> Subject:  Help with Variable Variables in Array
>
> Hi, all.  I can't quite figure out how to call the contents of a
> variable variable in a mysql_fetch_array result and was hoping someone
> could help . . .
>
> inside the "fetch all rows" while loop, i have the following:
>
> $right_row = "$" . myrow . "['" . $type . "_title']";
>
> ($type is assigned elsewhere, but in this case = 'article')
>
> which outputs:
>
> $myrow['article_title']
>
> So far so good, but i can't seem to output the value of this variable
> by printing
>
> $$right_row
>
> Any suggestions?
>
> TIA,
>
> Andrew
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17-Feb-06
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17-Feb-06
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux