php - Notice: Undefined variable in function += -


this question has answer here:

in couple scripts i've created same error when connect on wampserver.

every thing running smooth don't errors. notice: undefined variable

the $watdan function giving me error.

for example i've amounts need count up: 2835 + 11024 i've multipled those. when use code:

            $total[0] = $totaal->amount;             $total[1] = $totaal->price;             $watdan += $total[0] * $total[1]; 

im getting right answer 13859 i'm getting error i've mentioned.

now when add $watdan=0; 11024 without given error.

this full code:

    $pak14 = $db->query("select * log_drops inner join log_items on log_drops.item = log_items.name , log_drops.game = log_items.game log_drops.log_id = '".$id."' order log_drops.log_name asc") or die($db->error);     while($totaal = $pak14->fetch_object())     {              $total[0] = $totaal->amount;             $total[1] = $totaal->price;             $watdan += $total[0] * $total[1];         }      if(isset($watdan))     {         echo $watdan; echo ' gold';     } 

not declare variable $watdan. declare variable 0 or '' after use it.

$watdan=0;//add in code $total[0] = $totaal->amount; $total[1] = $totaal->price; $watdan += $total[0] * $total[1]; 

check

 $pak14 = $db->query("select * log_drops inner join log_items on log_drops.item = log_items.name , log_drops.game = log_items.game log_drops.log_id = '".$id."' order log_drops.log_name asc") or die($db->error); $watdan=0;//add in code while($totaal = $pak14->fetch_object()) {          $total[0] = $totaal->amount;         $total[1] = $totaal->price;         $watdan += $total[0] * $total[1];     }  if(isset($watdan)) {     echo $watdan; echo ' gold'; } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -