"Cannot redeclare class {...}" for user Model class in CodeIgniter 2.0.0-Dev (tip in hg) |
[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/) 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 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 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 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: <?php Controller (tosu_users.php): Code: <?php View (users_view.php): Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Any help or thoughts would be appreciated, thank you.
[eluser]mi6crazyheart[/eluser]
Make a small change in u'r controller file. Try it & tell me... Code: <?php
[eluser]Frank V[/eluser]
Thank you for your response. I made the adjustment as you suggested but I'm still getting the same error. Here is the revised controller... Code: <?php
[eluser]mi6crazyheart[/eluser]
Hey, u might've forget to mark one more thing in my suggested controller & that is... When u r accessing any model function u'r doing this Code: $this->Users->getAllUsers(); Code: $this->tOSU_Users->getAllUsers(); So, change this thing also inside of u'r controller & execute u'r script...
[eluser]Frank V[/eluser]
Good call -- I missed that. I made the change but it didn't change anything with regards to my error. Nevertheless, thanks for pointing that out.
[eluser]kaejiavo[/eluser]
Hi, your model class and controller class have the same name. i think this is not working. try renaming one of them. Marco
[eluser]Frank V[/eluser]
Mawi27, thanks. That did it. All the tutorials seemed to use the same name for the model and controller. I had been working under the assumption that that was a requirement of the framework. Anyway, thanks again! |
Welcome Guest, Not a member yet? Register Sign In |