ballhogjoni Posted April 3, 2007 Share Posted April 3, 2007 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> Link to comment https://forums.phpfreaks.com/topic/45362-warning-division-by-zero-in-homerealfinapublic_htmltestsschoolfindthebugs/ Share on other sites More sharing options...
fert Posted April 3, 2007 Share Posted April 3, 2007 if(isset($_POST['daysOnTrip'])) { $totalDollarsSpent=$_POST['totalDollarsSpent']; $daysOnTrip=$_POST['daysOnTrip']; $costPerDay=$totalDollarsSpent / $daysOnTrip; $weeks=$daysOnTrip / 7; $costPerWeek=$totalDollarsSpent / $weeks } Link to comment https://forums.phpfreaks.com/topic/45362-warning-division-by-zero-in-homerealfinapublic_htmltestsschoolfindthebugs/#findComment-220262 Share on other sites More sharing options...
ballhogjoni Posted April 3, 2007 Author Share Posted April 3, 2007 I tried that and it came up with this error: Parse error: syntax error, unexpected '}' in /home/realfina/public_html/tests/school/FindtheBugs.php on line 98 Link to comment https://forums.phpfreaks.com/topic/45362-warning-division-by-zero-in-homerealfinapublic_htmltestsschoolfindthebugs/#findComment-220264 Share on other sites More sharing options...
trq Posted April 3, 2007 Share Posted April 3, 2007 Please do NOT multipost, this question would be right at home with your last division by zero error. Locked. Link to comment https://forums.phpfreaks.com/topic/45362-warning-division-by-zero-in-homerealfinapublic_htmltestsschoolfindthebugs/#findComment-220266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.