View Full Version : Division by zero
03-12-2009, 10: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);
03-12-2009, 10:52 PM
One, some or all of your variables does not have a value.
03-12-2009, 10:57 PM
03-12-2009, 10:59 PM
($max - $old) * 100 = 0. You can't divide by 0; it is a mathematical impossibility.
03-12-2009, 11:01 PM
So what do i need to put.
03-12-2009, 11:15 PM
You can check to see if ($max - $old) * 100 is equal to zero prior to dividing by it.
03-13-2009, 05: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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.