Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.