asbjoern Posted June 17, 2008 Share Posted June 17, 2008 Hi I am new to PHP trying to make a small script, where the user can put 2 values: dagatal (which is number of days) inntoka (which is income) I have the following in a html form: <form id="grein25b" name="grein25b" action="grein25b.php" method="post"> <input name="dagatal" type="text" class="box" id="dagatal" size="20" value="0" tabindex="1"> <input name="inntoka" type="text" class="box" id="inntoka" size="20" value="" tabindex="2"> In the PHP script I have: <?php $newline = "<br />"; $dagaraar = 366; $datatal = $_POST['dagatal']; $inntoka = $_POST['inntoka']; $grundfradrattur = 0; $fradrattur15pct = 0; $fradrattur8pct = 0; //----- Check divison by zero ----------------------------------------- if ($dagatal == 0){ $dagatal = 366;} else { $dagatal = $dagatal; } $arsinntoka = ($inntoka * $dagaraar / $dagatal); It works fine on localhost, but when I put it on my website, I get error division by zero in the line: $arsinntoka = ($inntoka * $dagaraar / $dagatal); Can anyone help? Link to comment https://forums.phpfreaks.com/topic/110646-division-by-zero/ Share on other sites More sharing options...
Barand Posted June 17, 2008 Share Posted June 17, 2008 $datatal = $_POST['dagatal']; Link to comment https://forums.phpfreaks.com/topic/110646-division-by-zero/#findComment-567631 Share on other sites More sharing options...
asbjoern Posted June 17, 2008 Author Share Posted June 17, 2008 Sorry typed wrong: $datatal = $_POST['dagatal']; it is: $dagatal = $_POST['dagatal']; Link to comment https://forums.phpfreaks.com/topic/110646-division-by-zero/#findComment-567635 Share on other sites More sharing options...
MasterACE14 Posted June 17, 2008 Share Posted June 17, 2008 with this part you don't need the else <?php if ($dagatal == 0){ $dagatal = 366;} /* else { $dagatal = $dagatal; } */ Regards ACE Link to comment https://forums.phpfreaks.com/topic/110646-division-by-zero/#findComment-567693 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.