phpBBHacks.com - Cannot Redeclare Function error
Find affordable web hosting packages at iFroggy Hosting
StatsForums Home   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in
FAQFAQ   SearchSearch   MemberlistMemberlist   TutorialsTutorials   ContactContact Us
Username:    Password:
Remember Me?    
   I Lost My Password!
Bookmark and Share
Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Troubleshooting
 See a User Guidelines violation? Please contact us.
Author Message

Thoul
VIP

Joined: 30 Jul 2002
Posts: 18040
Location: USA

PostPosted: April 6th 2005, 11:31 pm    Post subject: Cannot Redeclare Function error Reply with quote

Quote:
Fatal error: Cannot redeclare function_name() (previously declared in file.php:10) in file.php on line 10


A variation of this error message sometimes appears after installing hacks or making certain other edits to your forum's files. In order to perform the variety of tasks that go into managing and displaying a forum, each page must process code stored in several different files. When this error is displayed, it is an indication that some code is either being processed twice or shares a name with another area of code.

To determine which case you are dealing with, compare the two file names mentioned in the error message. These are shown in green and red text in the example. When the two filenames are identical, this indicates that the page is attempting to process the named file more than once. Look at Case 1 below for a solution. If the two filenames are different, two pieces of code are sharing a name; this is covered in Case 2.


Last edited by Thoul on April 6th 2005, 11:38 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website

Thoul
VIP

Joined: 30 Jul 2002
Posts: 18040
Location: USA

PostPosted: April 6th 2005, 11:32 pm    Post subject: Reply with quote

Case 1: Processing a File Twice

The first step to fixing the error is to locate a certain line in the indicated file. The exact line you must find will vary from one instance of this problem to another, but the error message will give you two hints to help locate the line. Notice that in the example error message, the text function_name is bolded. Your error message will have something different in the place of function_name. Examples might be "get_userdata," "make_realdate" or "message_die." You need to locate a line that begins like this, replacing function_name with the matching text from your error message:
Quote:
function function_name(


So examples of the actual line to locate could be any of the following:
Quote:
function get_userdata(
function make_realdate(
function message_die(


Remember that you will be trying to find a line that begins with this text. In 99% of cases, there will be more text following this on the same line.

Once you have found the line, add the code below before it. Again, replace function_name with the text from the error message. Take care to match spelling exactly and preserve the single quotation marks.
Code:
if ( function_exists('function_name') )
{
   return;
}


The new code will prevent repeated processing of the file and put an end to the error.
Back to top
View user's profile Send private message Visit poster's website

Thoul
VIP

Joined: 30 Jul 2002
Posts: 18040
Location: USA

PostPosted: April 6th 2005, 11:42 pm    Post subject: Reply with quote

Case 2: Sharing a Name

On rare occasions, you might actually run into a case where some newly added hack is conflicting with existing code in phpBB or another installed hack. These are more difficult to fix than Case 1 errors because they tend to vary even more from case to case. If you are not an experienced PHP programmer that understands the flow of the files and code involved, it is better to seek assistance from the author of the hack you have recently added or the Support Forums than to attempt to fix this error yourself. At least two changes will likely be required, but many cases may require several more changes than this.
_________________
Fringes of Algo - Phantasy Star Community
TV Blitz Forums - Television Discussion Community
phpBB Smith: Modifications

70+ Listings @ phpBBHacks.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Troubleshooting All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Links: Big Message Boards - Free JavaScript - phpBB2 - phpbb styles - Suporte phpBB - phpBB Česky - phpBB Turkiye - phpBBArabia.com - phpBB-fr.com - Romanian phpBB online community - phpBB-TW.net - phpBBservice.nl - phpBB Brasil - phpBB Portugal - phpBBpersian.com

Network: iFroggy Hosting - PhotoshopForums.com - Managing Online Forums - ManagingCommunities.com - CommunityAdmins.com - KarateForums.com - Bad Boy Blog - SodaRatings.com - Patrick O'Keefe

< Advertising - Contact Us - Disclosure Policy - Staff - User Guidelines >

Copyright © 2001-2012. iFroggy Network, phpBBHacks.com. All Rights Reserved. Privacy Policy. We Support phpBBHacks.com (of course!).
Powered by phpBB © phpBB Group. phpBB SEO. We are in no way affiliated with the phpBB Group. phpBB is copyright to the phpBB Group.