Warning: Division by zero

newphpcoder
11:21:10
Good day I got a warning like this :
Warning: Division by zero in C:\Documents and Settings\LT\report.php on line 122

Warning: Division by zero in C:\Documents and Settings\LT\report.php on line 220

I have this code in line 22:
[PHP]
$yield = ($c_output / $f_input) * 100;
[/PHP]

and this is my code in line 220
[PHP]
$yield = ($sol_output / $buff_input) * 100;
[/PHP]

my c_output is = 65.17
f_input is = 68.40

so the result should be : 95.27 but on my output is 0.00%

and my sol_output = 0.00
buff_input = 0. 00

and the result is 0.00 % which is correct but why I got this warning.


Thank you
smo1234
11-22-2010
For Code at line 22 ,
It is giving correct result. Check that you have all your variables have correct value stored. Before the division print out them to screen once to verify that the data is correct. They must be flot to store the decimal values.

For Line number 220,
The warning message is justified but you can suppress the warning message by adding @ before the division.

$yield = @($c_output / $f_input) * 100;
Please Login to post your reply or start a new topic