I’m trying to do an Calculation of my Project
were I need to do Division and Multiplication to get my Ans
but getting an error "Uncaught DivisionByZeroError: Division by zero".
my Code and Error as shown in Screenshots
$total_plates=$row['s_tps'];
$total_a_kg=$row['s_kg'];
$plates_per_kg=$row['s_pkg'];
$remaing_kg=(1000/$plates_per_kg)*$total_plates;
echo "$remaing_kg";[![enter image description here][1]][1]
>Solution :
In the following line,
$remaing_kg=(1000/$plates_per_kg)*$total_plates;
if ‘$plates_per_kg’ value is 0, then this error will occur
Or "0", or null, or false, or array() or anything that intval would return 0 for.
Edit: Thanks for the comment @msbit