Jump to content

Warning: Division by zero


poe

Recommended Posts

i get this error message:

 

Warning: Division by zero in pro-showBBL.class.php on line ....

 

how do i avoid this error?

 

 

function calcL5ttlBBL($idTeam, $thePitcher, $what) {
$ttl_w = 0;
$ttl_l = 0;
$pitchL5 = getPitchL5($thePitcher);
for($x=0; $x<count($pitchL5); $x++) {
	if($pitchL5[$x]['wlt'] == "w") { $ttl_w = $ttl_w + 1; }
	if($pitchL5[$x]['wlt'] == "l") { $ttl_l = $ttl_l + 1; }
	if($pitchL5[$x]['ip'] ==0) { $ttl_ip = $ttl_ip + 0; } else { $ttl_ip = $ttl_ip + $pitchL5[$x]['ip']; }
	if($pitchL5[$x]['er'] ==0) { $ttl_er = $ttl_er + 0; } else { $ttl_er = $ttl_er + $pitchL5[$x]['er']; }
	if($pitchL5[$x]['h'] ==0) { $ttl_h = $ttl_h + 0; } else { $ttl_h = $ttl_h + $pitchL5[$x]['h']; }
	if($pitchL5[$x]['bb'] ==0) { $ttl_bb = $ttl_bb + 0; } else { $ttl_bb = $ttl_bb + $pitchL5[$x]['bb']; }
	if($pitchL5[$x]['hr'] ==0) { $ttl_hr = $ttl_hr + 0; } else { $ttl_hr = $ttl_hr + $pitchL5[$x]['hr']; }
	if($pitchL5[$x]['so'] ==0) { $ttl_so = $ttl_so + 0; } else { $ttl_so = $ttl_so + $pitchL5[$x]['so']; }
}
	$tblRow = "<tr>\n";
	$tblRow .= "<td align=right class=l5ttl>" . "TTL:</td>\n"; // game
	$tblRow .= "<td align=center class=l5ttl> </td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_w . "-" . $ttl_l . "</td>\n";
***ERROR ROW*** $tblRow .= "<td align=center class=l5ttl>" . sprintf( "%01.2f", (($ttl_er * 9)/$ttl_ip)) . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_ip . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_er . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_h . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_bb . "</td>\n";
***ERROR ROW*** $tblRow .= "<td align=center class=l5ttl>" . sprintf( "%01.2f", (($ttl_bb + $ttl_h)/$ttl_ip)) . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_hr . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . $ttl_so . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . "</td>\n";
	$tblRow .= "<td align=center class=l5ttl>" . "</td>\n";
	$tblRow .= "</tr>\n";



} // end function

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