I am getting an error when I use a plugin
I am getting the following error:
Fatal error: Cannot redeclare class WA_AltClassIterator in /var/www/html/adminx/members_results.php on line 114
I am getting the following error:
Fatal error: Cannot redeclare class WA_AltClassIterator in /var/www/html/adminx/members_results.php on line 114
Can I get a copy of the pages to look at? It sounds like a repeated include file, but they should be using require_once... maybe it is a function actually defined on the page itself? If you provide a copy of the plugin page I can look into it and offer a fix.
Please attach the actual file instead of copy/pasting the code. It is much easier to read when I can open it with Dreamweaver.
To fix this problem, replace this code:
<?php
//WA AltClass Iterator
class WA_AltClassIterator {
var $DisplayIndex;
var $DisplayArray;
function WA_AltClassIterator($theDisplayArray = array(1)) {
$this->ClassCounter = 0;
$this->ClassArray = $theDisplayArray;
}
function getClass($incrementClass) {
if (sizeof($this->ClassArray) == 0) return "";
if ($incrementClass) {
if ($this->ClassCounter >= sizeof($this->ClassArray)) $this->ClassCounter = 0;
$this->ClassCounter++;
}
if ($this->ClassCounter > 0)
return $this->ClassArray[$this->ClassCounter-1];
else
return $this->ClassArray[0];
}
}
?>
with this:
<?php
if (!class_exists("WA_AltClassIterator")) {
?>
<?php
//WA AltClass Iterator
class WA_AltClassIterator {
var $DisplayIndex;
var $DisplayArray;
function WA_AltClassIterator($theDisplayArray = array(1)) {
$this->ClassCounter = 0;
$this->ClassArray = $theDisplayArray;
}
function getClass($incrementClass) {
if (sizeof($this->ClassArray) == 0) return "";
if ($incrementClass) {
if ($this->ClassCounter >= sizeof($this->ClassArray)) $this->ClassCounter = 0;
$this->ClassCounter++;
}
if ($this->ClassCounter > 0)
return $this->ClassArray[$this->ClassCounter-1];
else
return $this->ClassArray[0];
}
}
?>
<?php
}
?>
That class must be defined on the main page or another plugin and having it twice is throwing the error. By wrapping it with an if statement that checks if it already exists, it should get around the problem.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.