Calculation in php goes wrong

时间:2015-11-12 11:21:25

标签: php

Something is wrong with my code, these are the errors displayed in the browser

Notice: Undefined offset: 86186 in F:\xampp\htdocs\Villa\berekening.php on line 28

Notice: Undefined offset: 123123 in F:\xampp\htdocs\Villa\berekening.php on line 29

Notice: Undefined offset: 123123 in F:\xampp\htdocs\Villa\berekening.php on line 30

Notice: Undefined offset: 369369 in F:\xampp\htdocs\Villa\berekening.php on line 34

I have no clue what I did wrong The errors

3 个答案:

答案 0 :(得分:4)

After reading you code I see that you're trying to do this :

Display $brutot, $netto, $spaargId.

But why are you trying to put them into a $_POST ?

Just do the following instead of your lines 28-30 :

echo $brutoTot;
echo $netto;
echo $spaargeld;

But you should also as Alex Andrei suggested check if your GET value are existing before using them to avoid any kind of undefined index so at the top of your PHP you should create your vars like below:

if(isset($_GET['netto'])){
    $netto = $_GET['netto'];
}
if(isset($_GET['bruto'])){
    $bruto = $_GET['bruto'];
}
if(isset($_GET['spaargeld'])){
    $spaargeld = $_GET['spaargeld'];
}
if(isset($_GET['ExtraInkomsten'])){
    $ExtraInkomsten = $_GET['ExtraInkomsten'];
}

答案 1 :(得分:0)

don't need to use $_POST just echo out the result

echo $brutoTot;
echo $netto;
echo $spaargeId;

答案 2 :(得分:-1)

The problem is that you have no $_POST values with those indexes. You can var_dump your $_POST to verify this and see what you can address.