Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Division by zero error  (Read 842 times)

envy002

  • Basic Member
  • *
  • Reputation Power: 22
  • envy002 has no influence.
  • Offline Offline
  • Posts: 5
    • View Profile
Division by zero error
« on: November 09, 2010, 07:30:36 PM »
i have a few errors showing on my index.php page when viewed in game....
 
first error is..
Warning: Division by zero in /home7/deadland/public_html/mainmenu2.php on line 4
visible on the top left hand ..

second error is...

Warning: Division by zero in /home7/deadland/public_html/header.php on line 135
this one is visible between the header.

any suggestions or help will be gladly appreciated.
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: Division by zero error
« Reply #1 on: November 09, 2010, 07:41:48 PM »
Show us the lines surrounding both of the lines listed in the errors
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

envy002

  • Basic Member
  • *
  • Reputation Power: 22
  • envy002 has no influence.
  • Offline Offline
  • Posts: 5
    • View Profile
Re: Division by zero error
« Reply #2 on: November 09, 2010, 08:21:36 PM »
this is mainmenu2.php... error stated in line 4.

1.<?php
2.global $ir,$c;
3.
4.$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
5.
6.$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
7.$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
8.
9.$wiopp=100-$wiperc;
10.$exopp=100-$experc;
11.$bropp=100-$brperc;
12.$hpopp=100-$hpperc;

these are in header.php error stated in line 135.

134.$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
135.$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
136.$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);
137.$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
138.$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
139.$enopp=100-$enperc;
140.$wiopp=100-$wiperc;
141.$exopp=100-$experc;
142.$bropp=100-$brperc;
143.$hpopp=100-$hpperc;

im perplexed!! cant figure it out!! thanx in advance  for any input..
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: Division by zero error
« Reply #3 on: November 11, 2010, 09:13:42 PM »
check all the variables and do the math equations to see which comes out to 0.
thats about the only way =/
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

envy002

  • Basic Member
  • *
  • Reputation Power: 22
  • envy002 has no influence.
  • Offline Offline
  • Posts: 5
    • View Profile
Re: Division by zero error
« Reply #4 on: November 13, 2010, 08:08:04 PM »
the game has been up for almost a year.. the error just showed up.. what could of changed?
Logged

Grips

  • Basic Member
  • *
  • Reputation Power: 30
  • Grips has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
    • Email
Re: Division by zero error
« Reply #5 on: November 15, 2010, 09:12:45 AM »
Well its clear by both of those its going to be a problem with whats in your will/maxwill.  Is this on ALL players or on a specific player?
Logged

envy002

  • Basic Member
  • *
  • Reputation Power: 22
  • envy002 has no influence.
  • Offline Offline
  • Posts: 5
    • View Profile
Re: Division by zero error
« Reply #6 on: November 15, 2010, 08:25:31 PM »
the will actually is working fine.... the error is visible in game, just below the header( game banner) and above the navigation on the left hand side.
Logged

Grips

  • Basic Member
  • *
  • Reputation Power: 30
  • Grips has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
    • Email
Re: Division by zero error
« Reply #7 on: November 16, 2010, 05:55:41 AM »
I am only going by what the error states.  When I have an issue related to variable values I just print them at the top to see what the values are.  depending on the variable you could simply print"$variable" if the return isnt what you expect you can try to use print_r($variable) as well.  The bottom line is you have a value that is zero and the math expects it to be higher.  Zero divided by anything is always zero.


this is mainmenu2.php... error stated in line 4.

1.<?php
2.global $ir,$c;
3.
4.$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
5.
6.$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
7.$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
8.
9.$wiopp=100-$wiperc;
10.$exopp=100-$experc;
11.$bropp=100-$brperc;
12.$hpopp=100-$hpperc;

these are in header.php error stated in line 135.

134.$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
135.$wiperc=(int) ($ir['will']/$ir['maxwill']*100);
136.$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);
137.$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);
138.$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);
139.$enopp=100-$enperc;
140.$wiopp=100-$wiperc;
141.$exopp=100-$experc;
142.$bropp=100-$brperc;
143.$hpopp=100-$hpperc;

im perplexed!! cant figure it out!! thanx in advance  for any input..
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: Division by zero error
« Reply #8 on: November 16, 2010, 07:21:28 AM »
When I have an issue related to variable values I just print them at the top to see what the values are.

This is what you must do, this is usually what I do as well.
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

Djkanna

  • Basic Member
  • *
  • Reputation Power: 0
  • Djkanna is looked down upon.
  • Offline Offline
  • Posts: 29
    • View Profile
Re: Division by zero error
« Reply #9 on: December 07, 2010, 06:24:20 PM »
The error is pretty obvious.

You cannot divide anything by zero as it will always end up being zero.


Now the best way to tackle this is to actually see what the value of said variable you're dividing by.
Once again poor coding from MCCodes.

Clearly you have a bug to do with your max will so I suggest heading to your database an taking a look to see your maxwill is set to 0.

Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.