Warning - how serious, how to eliminate

From: Date: Fri, 07 Sep 2001 10:36:19 +0000
Subject: Warning - how serious, how to eliminate
Groups: php.general 
Request: Send a blank email to php-general+get-66372@lists.php.net to get a copy of this message
Hello people, I've got a question regarding the follwing scripts that gives an error. When I execute the scripts below I get an warning-message: - Warning: Division by zero in ./scripts/fasen_include.php on line 47... This is the script I use. When the vars are set the value has to be added to $totaal and $weight, when not the var has to be skipped. At the end of the scripts $totaal is devided by $weight to get an average ($percentage). What can I do to eliminate the warning and is it serious? Regards, Bart #BEGIN PHP-SCRIPTS for (;;$fase[$i]) { $weight[$i] = ''; $totaal[$i] = ''; if (isset($fase[$i][f_d1_perc]) && !empty($fase[$i][f_d1_perc])) { if (isset($fase[$i][f_d1_weight]) && !empty($fase[$i][f_d1_weight])){ $weight[$i] += $fase[$i][f_d1_weight]; $totaal[$i] += ($fase[$i][f_d1_weight] * $fase[$i][f_d1_perc]); } } if (isset($fase[$i][f_d2_perc]) && !empty($fase[$i][f_d2_perc])) { if (isset($fase[$i][f_d2_weight]) && !empty($fase[$i][f_d2_weight])){ $weight[$i] += $fase[$i][f_d2_weight]; $totaal[$i] += ($fase[$i][f_d2_weight] * $fase[$i][f_d2_perc]); } } if (isset($fase[$i][f_d3_perc]) && !empty($fase[$i][f_d3_perc])) { if (isset($fase[$i][f_d3_weight]) && !empty($fase[$i][f_d3_weight])){ $weight[$i] += $fase[$i][f_d3_weight]; $totaal[$i] += ($fase[$i][f_d3_weight] * $fase[$i][f_d3_perc]); } } if (isset($fase[$i][f_d4_perc]) && !empty($fase[$i][f_d4_perc])) { if (isset($fase[$i][f_d4_weight]) && !empty($fase[$i][f_d4_weight])){ $weight[$i] += $fase[$i][f_d4_weight]; $totaal[$i] += ($fase[$i][f_d4_weight] * $fase[$i][f_d4_perc]); } } if (isset($fase[$i][f_d5_perc]) && !empty($fase[$i][f_d5_perc])) { if (isset($fase[$i][f_d5_weight]) && !empty($fase[$i][f_d5_weight])){ $weight[$i] += $fase[$i][f_d5_weight]; $totaal[$i] += ($fase[$i][f_d5_weight] * $fase[$i][f_d5_perc]); } } $percentage[$i] = $totaal[$i] / $weight[$i]; $percentage[$i] = number_format($percentage[$i],1, ',', ' '); #END PHP-SCRIPTS

« previous php.general (#66372) next »