Jump to content

[SOLVED] Division by Zero


phpbeginner

Recommended Posts

How can I fix a division by zero error if value is null or O ?

 

On my select statements above this code, I tried to only get values if field is not null but I still can't resolve the issue.

 

First 2 lines ($savep and $gaa) give the errors if value is NULL

 

$savep = number_format ($saves / $shots, 3, '.', ''); 
         $gaa = number_format ($diff * (60/$min), 2, '.', '');
    if($class=='text') $class=''; else $class='text';
    echo "<tr>
      <td class='$class' >$r[pnumber]</td>
      <td class='$class' ><a href='player.php?tid=1&pid=$r[pid]'>$r[pfname] $r[plname]</a></td>
      <td class='$class' align=center>$gplayed</td>
  <td class='$class' align=center>$shots</td>
      <td class='$class' align=center>$saves</td>
      <td class='$class' >$savep</td> 
      <td class='$class' >$gaa</td>
    </tr>";
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/177327-solved-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.