> -----Original Message-----
> From: Philipp Hartmann [mailto:[EMAIL PROTECTED]]
> Sent: 15 January 2003 12:50
> 
> Here is what I want to do:
> I am getting several variables into a Php Script such as:
> 
> help1 = "yes" / "no"
> help2 = "yes" / "no"
> .
> .
> .
> helpX = "yes" / "no"
> 
> I need to check whether the variable is true or false, and 
> according to that
> add
> 1 to a counter variable.
> 
> Something like this I'd do in ActionScript, but dont know about php
> [CODE]
> $i = 0;
> While (++$i <= 8) {
> if ([help]+$i=="yes"){ // this line produces an error...

I think you need to read the PHP manual page on variable variables:
http://www.php.net/manual/en/language.variables.variable.php -- and the one
on string operators:
http://www.php.net/manual/en/language.operators.string.php

> $counterYes += counterYes;

I assume this is a typo for $counterYes += 1 ...!
 
> }
> }
> [/CODE]
> 
> Do I have to initialize all variables before I can use them in php?

No -- but, presuming these values are coming from a form, or a query on the
URL, the other thing you need to take account of is the configuration
setting for register_globals.  If it's on, then fine, the above will work
with appropriate amendments to suit PHP syntax; if it's off, then you have
to use the $_POST[] or $_GET[] array as appropriate, and in fact the
variable variables stuff is not relevant because the array index is just the
HelpX string.

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, visit: http://www.php.net/unsub.php

Reply via email to