Jump to content
MakeWebGames

Recommended Posts

Posted

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 :)

Posted

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.

Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...