Newbie question?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joonas
Forum Newbie
Posts: 2
Joined: Thu Feb 27, 2003 5:13 am

Newbie question?

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Where do the values of $a1 - $a20 come from?

Mac
joonas
Forum Newbie
Posts: 2
Joined: Thu Feb 27, 2003 5:13 am

Post by joonas »

They came from form submission. It's my own test-yourself-script. ("Are you a romantic?")
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

$_POST['a1'] + $_POST['a2'] ......
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and poinfting to the sticky threads "Sticky: Before Post Read: ...",
esp. Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+
Post Reply