Page 1 of 1

Newbie question?

Posted: Thu Feb 27, 2003 5:13 am
by joonas
Whats wrong with this code?

<?

$score = $a1 + $a2 + $a3 + $a4 + $a5 + $a6 + $a7 + $a8 + $a9 + $a10 + $a11 + $a12 + $a13 + $a14 + $a15 + $a16 + $a17 + $a18 + $a19 + $a20;

print"$score";
?>


It print allways "0" when values of a1 ... a20 are something like 1,22 and 0,22


Thanks

Posted: Thu Feb 27, 2003 5:19 am
by twigletmac
Where do the values of $a1 - $a20 come from?

Mac

Posted: Sat Mar 01, 2003 2:07 pm
by joonas
They came from form submission. It's my own test-yourself-script. ("Are you a romantic?")

Posted: Sat Mar 01, 2003 3:38 pm
by bionicdonkey
$_POST['a1'] + $_POST['a2'] ......

Posted: Sat Mar 01, 2003 3:41 pm
by oldtimer
Explanation. If globals are off then you have to use the $_POST['a1'] as all values from a post are stored in a post array. If globals are on then $a1 will work. However is alway best in my opinion to code thinking they are off so that scripts are harder to spoof.

Jerry

Posted: Sat Mar 01, 2003 6:44 pm
by volka
and poinfting to the sticky threads "Sticky: Before Post Read: ...",
esp. Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+