Fatal Error Cannot Redeclare Class Users Codeigniter
here for a quick overview of the site Help Center Detailed answers to any questions you might php fatal error cannot redeclare class codeigniter have Meta Discuss the workings and policies of this site About cannot redeclare class model codeigniter Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads fatal error cannot redeclare class php with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up CodeIgniter: “Cannot redeclare class” up vote 0 down vote favorite Admittedly my OOPHP is a little shaky but I can't see what's wrong with this. In one of my controllers I'm including a utils sheet which, like the controller, extends the base CI_Controller class. This throws the fatal error: Fatal error: Cannot redeclare class Utils in {file path}\utils.php on line 88 Controller: class Dashboard extends CI_Controller { public function __construct() { //call parent constructor parent::__construct(); //load utils require 'application/helpers/utils.php'; //<-- utils loaded $this->utils = new Utils(); //<-- utils instantiated //load Dashboard model $this->utils->load->model('dashboard'); } //etc... } utils.php: class Utils extends CI_Controller { //prep for forms (on join or login views) public function prep_form() { $this->load->helper('form'); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/24284442/codeigniter-cannot-redeclare-class only takes a minute: Sign up PHP/Codeigniter cannot redeclare class - require_once and class_exists have failed me up vote 1 down vote favorite I've run into a bewildering problem in our CodeIgniter-powered website. One PHP class - TChild - will intermittently start throwing "cannot redeclare class" errors and breaking every page that uses it. The lengths I've gone to to http://stackoverflow.com/questions/12081863/php-codeigniter-cannot-redeclare-class-require-once-and-class-exists-have-fail ensure that the declaring code runs only once have gotten frankly ridiculous, but to no avail. The top of tchild.php currently looks like this: (!( isset( $GLOBALS['tchild_counter'] ) )) ? $GLOBALS['tchild_counter'] = 1 : $GLOBALS['tchild_counter']++ ; log_message("info", "tchild has been included " . $GLOBALS['tchild_counter'] . " times"); if($GLOBALS['tchild_counter'] != 1) { log_message("info", "STOP RUNNING TWICE"); } else { if ( ! defined('BASEPATH')) { log_message("error", "BASEPATH not set; no direct script access allowed"); exit('No direct script access allowed'); } log_message("info", "Basepath is fine, checking if tchild exists (proc".getmypid().")"); log_message("info", "why does that last line seem to run twice?"); if ( ! class_exists('TChild')) { log_message("info", "TChild does not exist, creating it"); if(class_exists('tchild')) { log_message("info", "tchild apparently exists?"); } else { log_message("info","okay, I'm extra-sure that tchild doesn't exist"); } class TChild extends ActiveRecord\Model { It's a gigantic pile of... something, but at least it should ensure that TChild is only defined once, right? Well, no. Mostly, it works fine, but occasionally the server will get into some strange state where it decides, despite all evidence to the contrary, that TChild i
redeclare class {...}" for user Model class in CodeIgniter 2.0.0-Dev (tip in hg) Thread Closed 0 Vote(s) - 0 Average 1 2 3 4 5 Thread Modes "Cannot redeclare class {...}" for http://forum.codeigniter.com/thread-33659.html user Model class in CodeIgniter 2.0.0-Dev (tip in hg) El Forum Unregistered #1 09-03-2010, 01:40 PM [eluser]Frank V[/eluser] I'm attempting to follow a tutorial to learn how to use CodeIgniter. (http://www.devshed.com/c/a/PHP/Building-...Framework/) https://www.daniweb.com/programming/web-development/threads/460459/codeigniter-showing-error-in-locale-php For my reasons, I've decided to learn from 2.0.0-Dev (which I realize the tutorials are written for ~1.7.x). (Note: I'm using Changeset: 476bf5866ee4) Nevertheless, I figure I'll learn the product better if I cannot redeclare use the newest and have to figure out the differences between 1.7.x and 2.0.0-Dev. Ok, that said -- I've run in to a problem that I do not understand. Quick info about me, I'm not an extremely experienced PHP coder. I'm coming from Django and Python. That said, I do know most of the basics about PHP (I think). I'm utilizing the latest version of cannot redeclare class WAMP (PHP 5.3, MySQL 5.1) & I'm developing on Windows 7. (I added xdebug to php) The exact error I'm getting is as follows: Code: (!) Fatal error: Cannot redeclare class tOSU_Users in C:\wamp\www\codeigniter\application\models\tosu_users.php on line 32
Call Stack
#TimeMemoryFunctionLocation
10.0004380320{main}( )..\index.php:0
20.0012439216require_once( 'C:\wamp\www\codeigniter\system\core\CodeIgniter.php' )..\index.php:163
30.01091121592tOSU_Users->tOSU_Users( )..\CodeIgniter.php:281
40.01541366104CI_Loader->model( )..\tosu_users.php:9 The crux of the error is: "Cannot re-declare class tOSU_Users in C:\wamp\www\codeigniter\application\models\tosu_users.php on line 32". (line 32 is the last line and is blank) The tutorial had me naming the model class as 'users' and I changed it to tosu_users to ensure there isn't a new class (in 2.0.0-dev that is called users.) Here is my full source code for the model (tosu_users.php): Code: class tOSU_Users extends CI_Model {
function tOSU_Users() {
//call constructor
parent::CI_Model();
//load the DB class and connect.
$this->load->database();
}
function getAllUsers() {
$query = $this->db->get('Users');
if( $query->num_rows() > 0 ) {
//return result set as associative array
return $query->result_array();
}
return null;
}
function getUsersWhere( $field, $param ) {
$this->db->where($fie
version for my real estate stie and it is working fine in local host xamp server. But when i uploaded in to server, the site not working , showing error as "Fatal error: Cannot redeclare class Locale in /application/libraries/Locale.php on line 12" pls help me how to solve this .. thanks in advance.. codeigniter error php system-error satheeshakira 20 posts since Aug 2013 Community Member 3Contributors 9Replies 24Views 3 YearsDiscussion Span 1 Year Ago Last Post by Walid_1 0 Szabi Zsoldos 26 3 Years Ago You are trying to redeclare the locale class in a file of yours. 0 Discussion Starter satheeshakira 3 Years Ago It is working fine in localhost, the problem exisiting in only server. 0 Szabi Zsoldos 26 3 Years Ago Please post the code where you are declaring your languages. 0 Discussion Starter satheeshakira 3 Years Ago I think its here, in local_helper.php function __($text, $domain = 'default') { $CI =& get_instance(); $CI->load->library('Locale1'); return $CI->locale1->tr($text, $domain); } function _e($text, $domain = 'default') { echo __($text, $domain); } And here is Locale.php class Locale1 { //initializing var $_data; var $locale; var $_l10n; var $table; var $codes; var $default; function Locale() { $this->table = ('languages'); $this->obj =& get_instance(); $this->codes = $this->get_codes(); $this->default = $this->get_default(); if (!$this->obj->session->userdata('lang')) { $this->obj->session->set_userdata('lang', $this->default); } log_message('debug', 'Locale Class Initialized'); } . . . . etc 0 Discussion Starter satheeshakira 3 Years Ago I have fixed the problem now, thanks. 0 Szabi Zsoldos 26 3 Years Ago You loaded the locale class, did you eliminate that and it worked ? 1 Discussion Starter satheeshakira 3 Years Ago I have renamed locale.php and its class name etc. 0 Szabi Zsoldos 26 3 Year