Jump to content

[SOLVED] Basic if statement involving math.


suttercain

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.