...

View Full Version : Division by zero



TrueG
03-12-2009, 09:48 PM
I get this error

Warning: Division by zero in /home/sites//public_html/mini.php on line 155

Line 155 is

$percent = round((($rankp-$old)/($max-$old))*100);

CyberPirate
03-12-2009, 09:52 PM
One, some or all of your variables does not have a value.

TrueG
03-12-2009, 09:57 PM
What ?

Fumigator
03-12-2009, 09:59 PM
($max - $old) * 100 = 0. You can't divide by 0; it is a mathematical impossibility.

TrueG
03-12-2009, 10:01 PM
So what do i need to put.

Fumigator
03-12-2009, 10:15 PM
You can check to see if ($max - $old) * 100 is equal to zero prior to dividing by it.

_Aerospace_Eng_
03-13-2009, 04:01 AM
Actually just check to see if $max-$old equal 0 before you divide by it since the * 100 is outside of the parentheses.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum