Jump to content
TNG Community

Fatal Error after 10.1 update


LDMathews

Recommended Posts

Fatal error: Cannot redeclare tng_db_connect() (previously declared in /home/lehighva/public_html/tng/tngconnect.php:2) in /home/lehighva/public_html/tng/tngconnect.php on line 20

I'm getting this error when I go to a TNG page through WordPress

My hosting services is trying to resolve the issues after they recompiled the server with the MySqli module. Now it really doesn't work. The error showing above existed before and after the server was updated.

Any help that can be provided would be greatly appreciated.

My website is www.lehighvalleygenealogy.com The WordPress portion is working fine.

Thanks.

Link to comment
Share on other sites

Roger,

I wanted to confirm that I had this problem after going to 10.1

I reviewed the file differences after the upgrade I see that Darrin placed the the following in begin.php


include("tngconnect.php");
$link = tng_db_connect($database_host,$database_name,$database_username,$database_password);

The tng_db_connect() function used to be in globallib.php and all individual files called it themselves through genlib.php.

The catch seems to come in the tng.php file of the wordpress plugin that includes the begin.php file in multiple locations which is probably calling the tng_db_connect() function more than once.

A quick fix for me was the following:

1. Copy the begin.php file from an earlier version and put it in my root tng folder, renaming it to begin_wp.php (In my case I used the one from 10.0.3)

2. Change all references from begin.php in the tng.php file located in the plugin folder to begin_wp.php

It was quick and not well thought out but it worked to get the site back up.

Gustave

Link to comment
Share on other sites

Roger,

I wanted to confirm that I had this problem after going to 10.1

I reviewed the file differences after the upgrade I see that Darrin placed the the following in begin.php


include("tngconnect.php");
$link = tng_db_connect($database_host,$database_name,$database_username,$database_password);

The tng_db_connect() function used to be in globallib.php and all individual files called it themselves through genlib.php.

The catch seems to come in the tng.php file of the wordpress plugin that includes the begin.php file in multiple locations which is probably calling the tng_db_connect() function more than once.

A quick fix for me was the following:

1. Copy the begin.php file from an earlier version and put it in my root tng folder, renaming it to begin_wp.php (In my case I used the one from 10.0.3)

2. Change all references from begin.php in the tng.php file located in the plugin folder to begin_wp.php

It was quick and not well thought out but it worked to get the site back up.

Gustave

Thank you Gustave. I'll try it.

Link to comment
Share on other sites

I'm away at RootsTech and FGS in Salt Lake City, but have found a few moments to look at this this evening. Here's what I've found...

Lines 1117-1120 of the tng.php plugin

    $link = @mysql_connect($database_host, $database_username, $database_password);
    if ($session_charset == 'UTF-8')
        @mysql_query("SET NAMES 'utf8'");
    if( $link && mysql_select_db($database_name, $link))
Change the instances of "mysql_" in that to say "tng_" so you have
    $link = @tng_connect($database_host, $database_username, $database_password);
    if ($session_charset == 'UTF-8')
        @tng_query("SET NAMES 'utf8'");
    if( $link && tng_select_db($database_name, $link))

This works for me. I had forgotten I must have done that earlier during the TNG 10.1 testing.

There are 29 other instances of "mysql_xxxx" queries being called in the plug in too, and I imagine that if you use combined logins and allow users to create accounts etc you'd probably need to change them all too. My sites don't use that so it hasn't been an issue for me.

I will be seeing Darrin again tomorrow hopefully, as well as eMailing him this evening about this, and I guess an updated version of the tng.php file is needed for TNG 10.1

Roger

Link to comment
Share on other sites

Marcus Zurhorst

I am getting a similar error message when upgrading from 10.0.3 to 10.1.

The tiny little difference that I see is, that my message complains about line 2 in the script.

I also updated the tng.php file from the WP plugin of course.

To be sure, I also tried the full installation instead of the update diff, but this did not make any difference.

I finally went back to my 10.0.3 backup because I have not enough spare time to work this out.

So, if anybody has a smart advice, I appreciate it very much.

Thanks a lot, regards,

Marcus

Link to comment
Share on other sites

Roger, I am testing 10.1 with wordpress locally and I discovered that even with the updated tng.php file with the corrected lines mentioned above, I am STILL getting the fatal error as follows:


Fatal error: Cannot redeclare tng_db_connect() (previously declared in :\xampp\htdocs\LarleeTree\html\tng\tngconnect.php:2) in C:\xampp\htdocs\LarleeTree\html\tng\tngconnect.php on line 20

However, when I applied Gustave's fix, everything worked fine. So I'm guessing it's more than just those few lines... which were correct in the tng.php file I used.

Link to comment
Share on other sites

Roger, I am testing 10.1 with wordpress locally and I discovered that even with the updated tng.php file with the corrected lines mentioned above, I am STILL getting the fatal error as follows:


Fatal error: Cannot redeclare tng_db_connect() (previously declared in :\xampp\htdocs\LarleeTree\html\tng\tngconnect.php:2) in C:\xampp\htdocs\LarleeTree\html\tng\tngconnect.php on line 20

However, when I applied Gustave's fix, everything worked fine. So I'm guessing it's more than just those few lines... which were correct in the tng.php file I used.

Have you tried changing all the instances of mysql_ in the tng.php file to tng_ ?

It's quite possible that on a site that makes any calls to tng.php for any of the functions related to signing in and/or validating users etc that these other functions are the point of failure.

I don't have any sites that require logins or has users apart from myself as Admin so haven't run into any issues that aren't solved by just changing the 3 lines mentioned above here.

I'm still in a severe "10 days away for research, RootsTech and sightseeing" backlog, so haven't had time to look at Gustave's fix much, but it seems to me that it's routing all calls to the TNG database back through the regular mysql_ calls that TNG itself has now abandoned.

Roger

Link to comment
Share on other sites

So - an update on this, and I guess a question on direction...

1 - the tng.php as updated and available from Darrin's download page works - AS LONG AS the "Integrate TNG/WordPress logins" is NOT checked. As soon as that's checked, and attempted to use it a whole bunch of problems arise as discussed above here and in other places - the whole thing fails because of the white screen issue and the error "Cannot redeclare tng_db_connect() (previously declared in xxxxxxxl\tng\tngconnect.php:2) in xxxxxxxx\tng\tngconnect.php on line 20"

I have futzed around with this for more than 4 hours this morning, and can't resolve the entire process, but have made progress in two different directions.

A - USING ONLY mysql_ calls and Gustave's suggestion of a new file called wp_begin.php

1 - using the TNG 10.0.3 version of tng.php (or getting the 10.1 version and reverting the 3 instances of tng_ in lines 1117-1120 back to mysql_ and change all instances of "begin.php" to "wp_begin.php". This lets the basic integration work.

2 - but as soon as someone attempts to register - either by clicking the link in the WordPress footer or sidebar, OR by clicking for a Register New Account in TNG (you end up at the same place in both cases - the WordPress register form - there are errors about being unable to include text.php on the Register form.

3 - this can be solved by adding these lines from the new begin.php (TNG 10.1) to wp_begin.php near the end before the closing ?>

$languages_path = "languages/";
include($cms['tngpath'] . "getlang.php");
4 - so now we have a form, free of error messages. And it "seems" to work for me, with a few other caveats (there are a number of columns in the tng_users table that aren't set to require a value, but the act of submitting the form indicates that they need a default value defined.) But the new User turns up in the TNG Users waiting for Review. B- CONVERTING TO USING DARRIN'S tng_ connect methods - this uses mysqli_ and so should be better in the long run due to the better performance and capabilities of mysql_ compared to the now deprecated mysql_ 1 - I have revised the tng.php plugin so that all but one of the calls that started mysql_ are now tng_. The exception is line 1131 which is a call to the WordPress database so must remain as mysql_ 2 - again, as soon as the "Integrate WordPress/TNG logins" is checked the white screen appears with the error message "Cannot redeclare tng_db_connect() (previously declared in xxxxxxxl\tng\tngconnect.php:2) in xxxxxxxx\tng\tngconnect.php on line 20" appears 3 - this can be worked around by changing line 10 of begin.php to
include_once("tngconnect.php");

This prevents the inclusion more than once of tngconnect.php and a site with "Integrate TNG/WordPress logins" checked will again work as expected.

4 - Now the login and registering appears is available, but doesn't entirely work - I'm still trying to figure that out, but have other things to do now today...

So now the questions:

1 - I wonder how many people use the "Integrate TNG/WordPress logins" setting - I don't, which is why I've not seen these issues until I set up a testing site to play around with all this

2 - Heather - how much of this is all handled by your meta plugin - does it handle all of the matters about creating users, checking that they don't exist in WordPress / TNG already, deleting them when needed etc etc etc? Or do you just hook to these functions in tng.php?

3 - ??

I'm wondering if the tng.php plugin shouldn't be stripped of all the complications about users and made to be solely for display of data as I and I know others use it, and leave the logging in and rights management to something designed to do only that - especially if Heather's Meta plugin already pretty much handles this?

Roger

Link to comment
Share on other sites

  • 3 weeks later...
HeatherFeuer

So - an update on this, and I guess a question on direction...

So now the questions:

1 - I wonder how many people use the "Integrate TNG/WordPress logins" setting - I don't, which is why I've not seen these issues until I set up a testing site to play around with all this

2 - Heather - how much of this is all handled by your meta plugin - does it handle all of the matters about creating users, checking that they don't exist in WordPress / TNG already, deleting them when needed etc etc etc? Or do you just hook to these functions in tng.php?

3 - ??

I'm wondering if the tng.php plugin shouldn't be stripped of all the complications about users and made to be solely for display of data as I and I know others use it, and leave the logging in and rights management to something designed to do only that - especially if Heather's Meta plugin already pretty much handles this?

Roger

Roger,

Sorry for missing this part of the conversation. I know that most of the users I've worked with integrate the logins, as do I. My plugin relies on the TNG plugin to handle user functions. That being said... it occurs to me that if I can figure out how to hook into the login functions (I've already figured out how to handle the registration part so that users registering through WordPress are successfully added to the review tab of TNG), perhaps we could split the TNG plugin as suggested above so that your plugin deals with display of data and my plugin handles all the user functions.

I have been playing with Kloosterman's method, which requires that both WordPress and TNG are installed in the same database (not really a problem at all and has been tested by others as being a bit faster). By sharing the database and making sure that I include wp-load.php in my scripts, I can use the $wpdb class to work with the TNG tables. So far I've been having issues getting TNG to recognize the sessions....

I know there must be a lot of WordPress/TNG users who, like you, don't need or want integrated logins and there may be others who would prefer to use Kloosterman's method but need the user functions. This might be the best solution for all situations. Perhaps this could be reposted to the WordPress forum?

Link to comment
Share on other sites

  • 1 year later...
Stephen Rowe

I realise this is an 'older' thread but still applicable for the WP-TNG plugin for TNG 11 and the newer WP 4.5.

To add the Heather's last post - I am attempting to move a Joomla!-TNG site over to WP-TNG installation - the issues with too many Joomla updates means I have been left too far behind in versions.

That being said, the main reason I selected Joomla! in the first place to use as a front end to TNG was its user integration - I could use Joomla! to register and validate all my users and then pass their UN and PW to TNG for TNG to also automatically validate.

Not having this capability in WP is, for me at least, a very bit minus. I need to be able to securely show documents via the front end (which TNG can't adequately handle (and shouldn't be expected to handle) and then 'hide' the TNG component from non-registered users of the front-end (if this makes sense which, obviously, it does to me).

Having said this - everything I tried to remove the redeclare problem from other threads failed to work - Gustav's solution, above, though was the only one that did work for me.

One of the reasons other solutions didn't work was the explanations given - in the main they were too 'techy' i.e. they weren't explicit enough with things like 'Use the code in this post' while the link would point to a thread and not an individual post and so, even trying all the code shown in the posts in the thread pointed to, failed to work or generated a completely new set of issues.

However, after all this I realise that what I want to try and achieve may not be possible. I certainly do not like the way TNG s made to appear inside a WP page. Depending on the theme being used, I have seen displays range from the width of the page used to 3 letter-columns wide )nice long page though!). In my Joomla! installation I managed to have TNG open in a new tab and, at the same time, pass along the UN/PW combination for an automatic sign-in - perfect. At this stage, it appears I can't do this with WP which makes me wonder whether I should stay with Joomla! (even at the 1.5 level) or suffer double validation that will be required under WP. It is only the fact WP is a more current and up to date piece of software that makes me continue, for the time being, top try and get a decent integration working.

Crossing my fingers on this one though...

Link to comment
Share on other sites

  • 2 months later...

Hi,

I was using an old WP version and TNG 10.0.3. No problem with WP/TNG intégration.

I'have update to  Wordpress 4.5.3 and to TNG 10.1.3.

Each items work fine in standalone usage. But TNG and WP integration was not working.

So I'have update module TNG Integration to version 9.0.0. I got this error (with my site informations) on "genalogy" pages.

Fatal error: Cannot redeclare tng_db_connect() (previously declared in :\xampp\htdocs\LarleeTree\html\tng\tngconnect.php:2) in C:\xampp\htdocs\LarleeTree\html\tng\tngconnect.php on line 20

I'have try the "Gustave" workarround. Fatal error for db_connect dispared but others error appears... So i restore tng.php .

With version 9.0.0 of the TNG Wordpress integration module :

  • Database erro is shown on "genealogy" pages.
  • Genealogy menu show on site frontpage but not on "genalogy" pages (as set in module option).
  • TNG do not show information in the specified page but when using the "Genealogy Database search" widget, it's work and show data in the page.

I do not want to go back to old installation. 

Can you help ?
Regards

 

Link to comment
Share on other sites

Hi Roger,

I've try to use a modified TNG.PHP (with tng_connect...) but do not solve problems.

I've change ligne 10 in tng/begin.php from include("tngconnect.php"); to include_once("tngconnect.php"); => error message desapear.

  • with new tng.php (version 9.0.0.0) => menu are not shown on genealogy page (but shown on from page). genealogy information do not show.
  • with old tng.php (version 2.0 for TNT 10.0.3) => menu are shown on genealogy page but genealogy information won't be on genealogy page : instead i got the genealogy menu (in the body part of the page)

Rollback to the suffusion theme version 4.4.7 do not solve probleme.BUT usage of the "Search people" form deliver a good page ! 

URL for checking : http://genealogie.derieppe.fr/genealogie/    (Site is in french)

So i do not have any more error message the link between WP and TNG is not efficient... URL link seem good (when you let the mouse over th elink) but where rewrite when clicking ... So i think probleme is in file ".htaccess" now...

thanks for your help...

Regards 

    Link to comment
    Share on other sites

    Something is wrong somehow - If I go to this

    http://genealogie.derieppe.fr/genealogie/

    I see a list of surnames on what seems to be this page

    http://genealogie.derieppe.fr/tng/surnames100.php?topnum=1000&tree=

    but on the Genealogy page.

    As you say, going to some other page like "Photos" it just gets re-written/re-directed back to the index.php page like you can see here

    http://genealogie.derieppe.fr/tng/index.php

    Can you post the content of your entire .htaccess file?

    How many .htaccess files are there - is there one in the root and one in the wp directory?

    Roger 

    Link to comment
    Share on other sites

    Hi Roger,

    Thanks for your help.

    i'have install WP and TNG in 2 subdirectory of site :

    • \rootdirectory\WP
    • \rootdirectory\TNG

    So I have 2  .htaccess files :

    • one in rootdirectoy
    • one in WP root directory.

    Because i use WP SUPER CACHE, these .htaccess files included lot of lines. So i replace both by a simple version :

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    Before answering your message, I spend lot of time for checking all settings in WP because i use REDIRECTION and WP SUPER CACHE extensions. After uninstall, clean (directories and databases) and done new install of theses modules > Nothing to say : all seems OK for all pages and URL except for "genealogy" pages.

    URL are always altered when clicking... (i leave the tng versoin 2.0 in TNG modules directory). Did you want i put the 9.0.0.0 Version (for TNG 10.1...) ? 

    Now i have no idea how to solve.... I you have no solution i think i will reinstall all (WP and TNG)...

    Regards

     

      Link to comment
      Share on other sites

      Did you put anything on the Genealogy page - i.e. does it have its own content, or is it completely blank?

      Does it make a difference if you disable ALL WordPress  plugins EXCEPT for the TNG-WordPress plugin?

      Yes, you should use the most recent version of the TNG-WordPress plugin available from the WordPress download page.

      As far as the TNG-WordPress plugin is concerned, the .htaccess file in the /wp/ directory should be empty - the only one with content should be in the root of your site.

      Roger

      Link to comment
      Share on other sites

      Hi Roger;

      1. The "Genalogy" page have few lines of text and include a view of "top 100 surnames" by this line  :  [slice src='http://genealogie.derieppe.fr/tng/surnames100.php?topnum=1000&tree=' tagless='true']
      2. When disableing all plugings excepts TNG Wordpress => always same problem...
      3. I have put the most recent version of TNG Wordpress files. 
      4. I have delete the  .htaccess file in the /wp/ directory

      Could it be a change in TNG files ?  I'have update to 10.1.0.3 (from 10.0.03).

      Regards

      Link to comment
      Share on other sites

      Try removing that text from the Genealogy page - it should be a blank page with zero content.

      If you want me to take a look send an eMail to rogerkiwi@aol.com with the following

      FTP login details - username and password
      WordPress Admin login details - username and password
      TNG Admin login details - username and password

      Roger

      Link to comment
      Share on other sites

      Hi Roger

      I'have made other testing with another WP site. Integration with TNG still broken ... Reasons are not really clear so i willl reinstall WP and TNG from "fresh" version in a few days. No time to do that now.

      Thanks for your help

       

      Link to comment
      Share on other sites

      • 3 weeks later...

      Hi,

      Coming back from hollidays.

      I have check with a new install of WP and a new install of TNG :

      => i had to edit the begin.php line 10 to change include("tngconnect.php"); by include_once("tngconnect.php");  => this should be fix in file revision by autor.

      => problem persist untill i find that problem was due to permalink option ! I'm sure it's work in previous versions of WP with the "%title%" option but now i need to choose the "%post_id%" option. Ugly solution for SEO but so far so good : genealogy data are back on site ! 

      2 points to solve : 

      1. I can't show the "genealogy menu" widget on the "genalogy" page. It's shown on other pages but not on the "genealogy" page... => so widget curently not active. This problem appears on version 9 of "WP TNG integration" extension
      2. the defaut "genealogy" shown is "index.php". Before my "genalogy" page show my introduction text and a list of surname. So i inderstand i have to edit the index.php ? 

      Regards

       

       

      Link to comment
      Share on other sites

      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.   Paste as plain text instead

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