Jump to content

division by zero


asbjoern

Recommended Posts

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

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.