danny420 Posted November 2, 2012 Posted November 2, 2012 Hi im not sure if this error has always been there but i just noticed it. It seems like it showed up after my game was spammed by some program that injects a bunch of usernames and into your database Any way heres the error code i am getting Warning: Division by zero in /home/kushcent/public_html/header.php on line 68 and when i navigate to line 68 i see this $experc = (int) ($ir['exp'] / $ir['exp_needed'] * 100); any help much apreciated :) Quote
rulerofzu Posted November 2, 2012 Posted November 2, 2012 Its maths...you cannot divide by 0 if you just had nonsense inputted into your database then its highly likely that this is the reason why. I would suggest you close the game, clean up your database, fix your game and then open it again. Quote
Octarine Posted November 2, 2012 Posted November 2, 2012 Warning: Division by zero in /home/kushcent/public_html/header.php on line 68 ... $experc = (int) ($ir['exp'] / $ir['exp_needed'] * 100); Which suggests that $ir['exp_needed'] is zero does it not? -- IIRC the exp_needed is calculated in the function check_level() in globals.php, something along the lines of pow($ir['level'] + 1, 3) * 2.2 which even for a missing, or null level would produce a semi-sane value therefore the problem is elsewhere. echo / print_r / var_dump is your friend here - ie try inserting something like: echo "<pre>"; print_r($ir); echo"</pre>"; just prior to line 68. Does the contents look sane? Are you looking at the right database? etc etc. Quote
Spudinski Posted November 2, 2012 Posted November 2, 2012 /offtopic Its maths...you cannot divide by 0 False. http://en.wikipedia.org/wiki/Division_by_zero#Abstract_algebra Quote
rulerofzu Posted November 2, 2012 Posted November 2, 2012 Depending on the maths and its application then yes in some cases what I stated is false. However in this application its true hence the error thrown as that how they have designed PHP to work. Now if you wish to make a more complex calculation to make it work in PHP then by all means do so. Quote
sniko Posted November 3, 2012 Posted November 3, 2012 OP - look into try/catch, this may help with dividing by zero :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.