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" <[EMAIL PROTECTED]>
To: "Php-General" <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to