Warning: Division by zero error

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
sweet160
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Feb 14, 2008 12:11 am

Warning: Division by zero error

Post by sweet160 » Sat Feb 23, 2008 11:50 pm

Hi,

After I uploade my site I got this division by zero error.

Here is the code

if ($color_index && isset($tab_colors[($tab_index)%count($tab_colors)])) {
$id .= $tab_colors[($tab_index)%count($tab_colors)];
$tab_index++;

}


ANybody know how do I can fix this?

Thanks!

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: Warning: Division by zero error

Post by Rogue4ngel » Sun Feb 24, 2008 4:30 am

Sounds more like an installation issue than it does a coding problem (you haven't done any custom coding to the site, have you?). What version of Joomla are you using?
If you're not a part of the solution, you're a part of the problem.

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Warning: Division by zero error

Post by ianmac » Sun Feb 24, 2008 5:43 am

sweet160 wrote:Hi,
if ($color_index && isset($tab_colors[($tab_index)%count($tab_colors)])) {
$id .= $tab_colors[($tab_index)%count($tab_colors)];
$tab_index++;
}
Division by zero errors indicate you are dividing by zero - the value of this is undefined.

The only thing you are dividing by in here is count($tab_colors).

Change if to:
if ($color_index && count($tab_colors) != 0 && isset($tab_colors[($tab_index)%count($tab_colors)])) {


Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

sweet160
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Feb 14, 2008 12:11 am

Re: Warning: Division by zero error

Post by sweet160 » Sun Feb 24, 2008 7:29 am

Ian,

Your the man! Its ok now, the errors are gone, and my website looks great thanks to you!

I cannot thank you enough

CHeers dude

ryanmcgr

Re: Warning: Division by zero error

Post by ryanmcgr » Fri Mar 07, 2008 4:37 pm

Hey guys,
I'm also getting a division by zero error - Warning: Division by zero in /home/paradise/public_html/home/templates/rt_modbusiness/rt_splitmenu.php on line 63

This is the chunk of code.. any ideas? Thanks a bunch

Code: Select all

				}
			}
			break;
			case 'content_typed':
			default:
			$mitem->link .= '&Itemid='. $mitem->id;
			break;
		}
default: is the line 63

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: Warning: Division by zero error

Post by Rogue4ngel » Mon Mar 10, 2008 1:31 pm

I don't see a division problem there. Could be the item is null (doesn't exist)? I'm not sure.
If you're not a part of the solution, you're a part of the problem.


Post Reply