Jump to content

[SOLVED] Division by zero


KeeganWolf

Recommended Posts

I have a loop thats displaying information from my mysql database, but the resulting page keeps displaying

Warning: Division by zero in /home/content/........./b2_wf.php on line 56

 

I'm in a scenario where I can't help that these values will often be zero, and I would like to just keep the warning from showing if possible.

 

Any ideas?

 

Here's a sample of the code

 

echo "<form method='post' action='pr_b2_wf.php'>";
$result = mysql_query($query) or die(mysql_error());
$content = <<<CONT
<table width ="800" border="1" align="center">
<tr>
<th></th>
<th>Product ID</th>
<th>Description</th>
<th>Quantity</th>
<th>Case Count</th>
<th>Build2</th>
</tr>
CONT;
while($row = mysql_fetch_array($result)){
$caseb2 = ($row['buil2'] / $row['quancase']); <--- error occurs here
$caseb2 = round($caseb2, 2);
$content .= <<<CON
<tr>
<td><input type='hidden' name='prod[$i]' value='{$row['prod']}'></td>
<td>{$row['prod']}</td>
<td>{$row['desc']}</td>
<td>{$row['quant']}</td>
<td>{$row['quancase']}</td>
<td><input type='text' name='buil2[$i]' value='{$caseb2}'></td>
</tr>
CON;
++$i;
}
$content .= "</table>";
echo $content;

Link to comment
https://forums.phpfreaks.com/topic/161827-solved-division-by-zero/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.