Jump to content

Fatal error: Cannot redeclare


timm211

Recommended Posts

Hello superior PHP gods.

I have a vexing problem, and if someone could help I'd be REALLY grateful. Here's the context:

 

I'm building a family history site, www.bennion.org. I've integrated a genealogy software The Next Generation (TNG) with a Wordpress backend. A guy created a WP plugin that integrates TNG with Wordpress, but no longer supports it. It works except that when I log into the Wordpress admin area, then return the page where I've integrated TNG (Family Tree), I get the following error message:

 

Fatal error: Cannot redeclare tng_header() (previously declared in /home/content/b/e/n/bennion/html/wp-content/themes/outreach/genealogy/genlib.php:44) in /home/content/b/e/n/bennion/html/wp-content/themes/outreach/genealogy/genlib.php  on line 107

 

If I refresh the page, it goes away and keeps working, but it scares non-technical usersand obviously isn't a good experience. I'll attach both the genlib.php file, as well as the TNG Wordpress plugin file...if anyone could figure out what's happening I'd be really grateful!!

 

Many thanks,

Tim

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Ok, thanks to user Mchl, I figured it out...

 

Mchl directed me to this post: http://www.phpfreaks.com/tutorial/defining-a-php-function-only-once

 

So I went through and added the

if(!function_exists('example')){

line (with a } to close) on the tng_header, as well as the 50 or so other functions in that file. Pain in the butt, and probably not the cleanest way to do it, but it works now.

 

Thanks!

Tim

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.