Hack Forums
[PHP] Division by zero - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Division by zero (/showthread.php?tid=5872258)



Division by zero - Truth3356 - Aug 10, 2018

i keep getting this error :
Division by zero (E_WARNING) /var/www/html/Panel/five/wPAIANY/page/data.inc.php (86 line)


My code still works , i just want to know how i can fix this


RE: Division by zero - Don Vito Corleone - Aug 10, 2018

Quote:A division by zero error can occur in PHP whenever:

The variable you’re dividing with has been set to zero (this number is called the divisor).
The variable you’re dividing with has been set to null.
The variable does not exist. i.e. It has not been set.


I can't really help without seeing the code, but it is probably due to one of the above reasons.

In general, you can use an if statement to not let your code run until a variable has been set, maybe this can help you:

Code
if(isset($yourVariableCausingProblems)) {
        // Your Code
}

or even this:

Code
if($yourVariableCausingProblems > 0) {
        // Your Code
}



RE: Division by zero - Truth3356 - Aug 10, 2018

(Aug 10, 2018 10:35 AM)Don Vito Corleone Wrote:  I can't really help without seeing the code, but it is probably due to one of the above reasons.

In general, you can use an if statement to not let your code run until a variable has been set, maybe this can help you:

Code
if(isset($yourVariableCausingProblems)) {
       // Your Code
}

or even this:

Code
if($yourVariableCausingProblems > 0) {
       // Your Code
}

heres all my code:

https://pastebin.com/2yHvr4LF


RE: Division by zero - Nachfolger - Aug 10, 2018

(Aug 10, 2018 03:15 PM)Truth3356 Wrote:  heres all my code:

https://pastebin.com/2yHvr4LF
Good job.

https://prnt.sc/kh85d8


RE: Division by zero - Bluffer - Aug 10, 2018

With pastebin first of all make sure it's public so everybody can see it.

Secondly use these tags in your post here so it can embed the code into your post!

Quote:[paste]link here[/paste]