Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-12-2009, 09:48 PM   PM User | #1
TrueG
New Coder

 
Join Date: Jan 2009
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
TrueG is an unknown quantity at this point
Division by zero

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);
TrueG is offline   Reply With Quote
Old 03-12-2009, 09:52 PM   PM User | #2
CyberPirate
Regular Coder

 
Join Date: Jan 2009
Location: Norway
Posts: 118
Thanks: 8
Thanked 2 Times in 2 Posts
CyberPirate is an unknown quantity at this point
One, some or all of your variables does not have a value.
CyberPirate is offline   Reply With Quote
Old 03-12-2009, 09:57 PM   PM User | #3
TrueG
New Coder

 
Join Date: Jan 2009
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
TrueG is an unknown quantity at this point
What ?
TrueG is offline   Reply With Quote
Old 03-12-2009, 09:59 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
($max - $old) * 100 = 0. You can't divide by 0; it is a mathematical impossibility.
__________________
Fumigator is offline   Reply With Quote
Old 03-12-2009, 10:01 PM   PM User | #5
TrueG
New Coder

 
Join Date: Jan 2009
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
TrueG is an unknown quantity at this point
So what do i need to put.
TrueG is offline   Reply With Quote
Old 03-12-2009, 10:15 PM   PM User | #6
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You can check to see if ($max - $old) * 100 is equal to zero prior to dividing by it.
__________________
Fumigator is offline   Reply With Quote
Old 03-13-2009, 04:01 AM   PM User | #7
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Actually just check to see if $max-$old equal 0 before you divide by it since the * 100 is outside of the parentheses.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:58 AM.


Advertisement
Log in to turn off these ads.