You are here: Re: Does PHP5 support dynamic variables? « PHP Language « IT news, forums, messages
Re: Does PHP5 support dynamic variables?

Posted by Aaron Saray on 09/28/07 04:15

On Sep 27, 7:35 pm, "peter" <sub...@flexiwebhost.com> wrote:
> > What I really need some help with was understanding why $categoryvalue
> > would
> > be empty.
>
> Try echoing out $tempbox and see if it looks as expected. Ensure that a
> variable exists with the name of what it choes out. Another thing you could
> do is ensure you have all errors being reported (error_reporting(E_ALL);).
> If $tempbox is not outputting what is expected then I would expect an error
> message stating an undefined variable such as:-
>
> Notice: Undefined variable: b in php-file on line 4
>
> This indicates that variable b has not been defined yet I am trying to use
> it.

Lets make the assumption that your categoryid is a numeric value...
and its going 1, 2, 3, etc... for all of your values and the
categories corresponding are dog, cat, fish

categoryid, category
1, dog
2, cat
3, fish



So the first time through, you're going to have this::

//1st iteration:
//categoryval lets say this is 'dogs'
$categoryval = $categoryrow["category"];

//categoryidval = 1
$categoryidval = $categoryrow["categoryid"];

//tempbox = 'box1'
$tempbox = "box" . $categoryidval;

//$tempbox = 'box1'... variable of that means we're looking for a
variable named $box1 now.
$categoryvalue = ${$tempbox};

Was $box1 defined? No? could be blank categoryvalue then.

As suggested above, turn up your error_reporting... also maybe paste
in any other relevant details - ie, where is $box1 being defined?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация