+ Reply to Thread
Results 1 to 5 of 5

Thread: Problem redeclaring news

  1. Join Date
    Nov 2006
    Posts
    5

    Problem redeclaring news

    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?

  2. Join Date
    Aug 2004
    Posts
    781

    Re: Problem redeclaring news

    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.

  3. Join Date
    Nov 2006
    Posts
    5

    Re: Problem redeclaring news

    - 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.

  4. Join Date
    Aug 2004
    Posts
    781

    Re: Problem redeclaring news

    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.

  5. Join Date
    Nov 2006
    Posts
    5

    Re: Problem redeclaring news

    eek. alright, thank-you mucho for explaining it

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts