Re: Warning - how serious, how to eliminate

From: Date: Fri, 07 Sep 2001 10:41:38 +0000
Subject: Re: Warning - how serious, how to eliminate
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66374@lists.php.net to get a copy of this message
ichange that line to if($weight[$i]) $percentage[$i] = $totaal[$i] / $weight[$i]; All tho this does mean that if $weight[$i] is zero then $percentage will be as well HTH, Tom ----- Original Message ----- From: "Bart Verbeek" <b.verbeek@creative-edge.nl> To: "Php-General" <php-general@lists.php.net> Sent: Friday, September 07, 2001 11:36 AM Subject: [PHP] Warning - how serious, how to eliminate > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#66374) next »