Jump to content

[SOLVED] Warning: Division by zero in /home/realfina/public_html/tests/school/FindtheBugs


ballhogjoni

Recommended Posts

How do I get rid of this warning message?

 

Warning: Division by zero in /home/realfina/public_html/tests/school/FindtheBugs.php on line 48

 

<?php
$milesTraveled=$_POST['milesTraveled'];
$gallonsOfGasUsed=$_POST['gallonsOfGasUsed'];
$milesPerGallon = $milesTraveled / $gallonsOfGasUsed;
?>
<form action="" method=POST>
<table width="300" align="center">
<tr><td align="center"><h2><b>Question 2</b></h2></td></tr></table>
<table width="300" align="center">
<tr>
<td align="right">
Miles Traveled</td><td><input type="text" name="milesTraveled" value="" />
</td>
</tr>
<tr>
<td align="right">
Gallons Of Gas Used</td><td><input type="text" name="gallonsOfGasUsed" value="" />
</td>
</tr>
</table>
<table width="300" align="center">
<tr>
<td width="10">
</td><td align="center"><input type="submit" value="Find the Miles Per Gallon" />
</td></tr></table>
<table align="center" width="300">
<tr>
<td align="center">
The average of the Miles Traveled & the Gallons Of Gas Used you just submitted is: <span style="background-color:#FFFF00"><font color="#FF0000"><b>
<?php 
if ($milesPerGallon=="0")
echo "First you must input some numbers in the form above and then click the \"Find the Miles Per Gallon\" button";
else 
echo $milesPerGallon;?></b></font></span>
</td>
</tr>
</table>
</form>

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.