Skip to content
Advertisement

“Division by zero” PHP [closed]

What could be the cause of this error? I already check it with if/else statement in the first level. How can it still show the “Division by zero” error?

if($sum != 0) {
    $percent = (($sum / $tss) * 100);
} else {
    $percent = 0;
}

Advertisement

Answer

You check $sum. You should be checking $tss.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement