Jump to content

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


ballhogjoni

Recommended Posts

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

 

<?php
if(isset($_POST['daysOnTrip']))
{
$totalDollarsSpent=$_POST['totalDollarsSpent'];
$daysOnTrip=$_POST['daysOnTrip'];
$costPerDay=$totalDollarsSpent / $daysOnTrip;
}
$weeks=$daysOnTrip / 7;
$costPerWeek=$totalDollarsSpent / $weeks
?> // this is line 99

<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">
Total Dollars Spent</td><td><input type="text" name="totalDollarsSpent" value="" />
</td>
</tr>
<tr>
<td align="right">
Days On Trip</td><td><input type="text" name="daysOnTrip" value="" />
</td>
</tr>
</table>
<table width="300" align="center">
<tr>
<td width="10">
</td><td align="center"><input type="submit" value="Find the Cost Per Day & the Cost Per Week" />
</td></tr></table>
<table align="center" width="300">
<tr>
<td align="center">
The Cost Per Day & the Cost Per Week is: <span style="background-color:#FFFF00"><font color="#FF0000"><b>
<?php 
if ($costPerDay=="0" && $costPerWeek=="0")
echo "First you must input some numbers in the form above and then click the \"Find the Cost Per Day & the Cost Per Week\" button";
else 
echo $costPerDay. " / " .$costPerWeek;?>
</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.