View Full Version : Problem redeclaring news
artoonie
11-22-2006, 03:47 PM
Test page: http://mrspiffy.biz/news/test.php
Error message: Fatal error: Cannot redeclare news() in /home/www/mrspiffy.biz/news/news.php on line 281
How do I fix this?
Patrick
11-23-2006, 12:13 AM
The functions are contained within classes and the classes are specifically named. Obviously the script doesn't include such a serious bug and thus it must be a configuration issue.
Some questions:
- How are you including the script?
- Are you including the script twice (which could cause problems if not using include_once or require_once)?
- Have you modified the script's files?
- Do you have the script including itself somehow (could cause serious problems)?
I need more information since this does not appear to be a script bug but a user configuration error.
artoonie
11-25-2006, 01:19 AM
- How are you including the script?
- Are you including the script twice (which could cause problems if not using include_once or require_once)?
- Have you modified the script's files?
- Do you have the script including itself somehow (could cause serious problems)?
It doesn't work on the test file, so I'm including the default way, im not including twice, and i havent included the script. i only edited the script to replace all "EP-DEV-FORUM-NEWS" to "NEWS" because I changed the directory.
Patrick
11-25-2006, 02:33 AM
That is your problem then.
By modifying the class name (which is entirely unnecessary), you also changed the constructor name. Since you changed the constructor name to "news", a new "news" function has been created and as a result the original "news" function is going to throw an error (since the new "news" name of the constructor is declared first).
Thus, PHP is throwing "Cannot redeclare..." since you have, essentially, created a new news function by modifying the class name / constructor function name.
There is no need to modify the the class name. The only reason(s) you should ever have to modify a class name would be if you already had a class named "EP_Dev_Forum_News" which is highly unlikely (one reason I chose that class name) or if you were attempting to integrate it into a system that uses a strict naming structure (highly unlikely as well, since to integrate into such a system you would probably need a wrapper script anyway).
The good news is that the solution is simple :)
Simply upload a new unmodified version of the entire script and reinstall.
artoonie
11-26-2006, 07:10 PM
eek. alright, thank-you mucho for explaining it :)
Powered by vBulletin™ Version 4.0.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.