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
https://forums.phpfreaks.com/topic/207537-fatal-error-cannot-redeclare/
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

 

Archived

This topic is now archived and is closed to further replies.

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