My Website? PhP

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

My Website? PhP

Post by Chromeozone »

Hey Guys,

I havnt posted in a long time, I just generally read the forums and see whats going on :)

But today, I have had a problem!

http://www.darkseaadventures.com/Arcade ... /index.php

Doesnt seem to work?

Please can I have some help to resolve this issue?
Image
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

Re: My Website? PhP

Post by Chromeozone »

After editing some settings on firefox I was able to turn off some network settings, finding the error

Warning: Division by zero in /.../..../public_html/Arcade/Dragon-Knights/lib.php on line 227

Warning: Division by zero in /..../..../public_html/Arcade/Dragon-Knights/lib.php on line 229

Code: Select all

   // HP/MP/TP bars.
        $stathp = ceil($userrow["currenthp"] / $userrow["maxhp"] * 100); 
        if ($userrow["maxmp"] != 0) { $statmp = ceil($userrow["currentmp"] / $userrow["maxmp"] * 100); } else { $statmp = 0; }
        $stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100); 
        $stattable = "<table width=\"100\"><tr><td width=\"33%\">\n";
        $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
        if ($stathp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
        if ($stathp < 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
        if ($stathp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
        $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
        $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
        if ($statmp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
        if ($statmp < 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
        if ($statmp < 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
        $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
        $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
        if ($stattp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
        if ($stattp < 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
        if ($stattp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
        $stattable .= "</td></tr></table></td>\n";
        $stattable .= "</tr><tr><td>HP</td><td>MP</td><td>TP</td></tr></table>\n";
        $userrow["statbars"] = $stattable;
Here is lib.php and Line 227 = $stathp = ceil($userrow["currenthp"] / $userrow["maxhp"] * 100);
Here is lib.php and line 229 = $stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100);
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: My Website? PhP

Post by hallsofvallhalla »

still doesnt work for me.
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

Re: My Website? PhP

Post by Chromeozone »

What do you mean?
Image
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

Re: My Website? PhP

Post by Chromeozone »

Still can't work it out xD
Last edited by Chromeozone on Mon Feb 09, 2015 12:34 am, edited 1 time in total.
Image
User avatar
Foofighter
Posts: 121
Joined: Sun Mar 04, 2012 1:52 pm

Re: My Website? PhP

Post by Foofighter »

mhm u posted just a link and expect us to know what your problem is?
is there still a problem?

As far as i can tell your index is working.

regards
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: My Website? PhP

Post by Chris »

That error was most likely happening because you're dividing by an undefined variable. Either $userrow["currenthp"] or $userrow["maxhp"] were not set, PHP then casts the null values to an integer because of the division operator, so you end up trying to divide by 0, which is impossible.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: My Website? PhP

Post by hallsofvallhalla »

When I went to the link it said page not found. So I tried but could not even get to the page. :) Sorry man.
Post Reply

Return to “Beginner Help and Support”