suttercain Posted May 6, 2007 Share Posted May 6, 2007 I everyone, I am running the following code: $total = 0; if ($total > 0); { $average = $sum/$total; echo "Sum: $sum / Total: $total"; } When I try to tun the code I get the following error: Warning: Division by zero in /home/superman/public_html/comics/comicvote.php on line 14 I understand that division by 0 is not allowed, but shouldn't the if statement prevent that division from running? Thanks. Link to comment https://forums.phpfreaks.com/topic/50204-solved-basic-if-statement-involving-math/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.