Home php How to Fix - PHP Warning: Division by Zero?

How to Fix – PHP Warning: Division by Zero?

Author

Date

Category

In the management of the game server (Sourcebans ++ 1.6.3) there is such an error (more precisely in the logs of the subdomain on which it is located):

[Fri May 22 09: 29: 30.770872 2020] [PHP7: WARN] [PID 10749] [Client IP: Port] PHP Warning: Division by Zero In / Var / WWW / WWW-Userroot / Data / www / bans.mysite.ru / includes / smarty / plugins / function.math.php (94): eval () ‘D code on line 1, referer: iphost

Here is a string that he “complains”:

eval ("\ $ smarty_math_result =". $ equation. ";");

Here is the link full code
https://pastebin.com/d6wshcc1

Can I fix it?


Answer 1, Authority 100%

Error inside Smarty functions is caused by incorrect input data. In general, the use of such functions here is very redundantly and excessively complicates the code of the template (I can not imagine anything in SMARTI in principle such a functional).

Clean the desired values ​​in the template.

{$ nc = $ smarty.now - $ ban_times [$ index] .c}
{$ EC = $ Ban_Times [$ index] .e - $ smarty.Now}
{$ w = $ EC? ($ NC / $ EC / 100): "Some value"}
& lt; DIV Class = "Progress-Bar BG-Warning Progress-Bar-Striped Progress-Bar-Animated"
   ROLE = "PROGRESSBAR" ARIA-WIDTH = "{$ w}" & gt;

It is not particularly particularly similar that the error in this template, since the denominator compares $ smarty.now , that is, the current timestamp. And the likelihood that it coincides is not great. So I would get rid of you at all from all inclusions {Math ...} from templates.

and in case you have all this case is displayed in the form of

{foreach $ ban_times as $ index = & gt; $ V}

In the formulas, you can use {$ v.c}, {$ v.e} and not {$ ban_times [$ index]}

Previous articleGet a link to Python
Next articlewall.post python vk

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions