WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Fatal error: Cannot redeclare class wpdb in.... db.php line 54 (8 posts)

  1. karenratte
    Member
    Posted 2 years ago #

    I am SOOO frustrated. I am not a programmer and was simply trying to set in motion a caching plugin when I got this fatal error.
    Fatal error: Cannot redeclare class wpdb in /home/essent11/public_html/videosite/wp-content/db.php on line 54
    I had to rename the db.php to get back to the website. I don't even know if it is required, but I am guessing that it is...
    what do I need to do to get my site back to normal please? I am not even sure which file it hosed or if there is some Cache I need to clear somehow. Any tell me how I can fix this short of starting over?
    thanks

  2. kobashicomputing
    Member
    Posted 2 years ago #

    Deactivate the plugin and remove it. It is likely incompatible with your version of WordPress.

    Try W3 Total Cache. Its widely used and the most popular caching plugin out there. Make sure you got the current version of WP running.

  3. karenratte
    Member
    Posted 2 years ago #

    What plugin? from what I can see it is W3 Total Cache that caused it. What is db.php anyway?

  4. kobashicomputing
    Member
    Posted 2 years ago #

    What plugin? The cache plugin that is causing your problem of course.
    Whenever you run into a problem of installing a new plug in, the solution is to deactivate it, delete it. Then check to see if your website works.

    If it does, then you pinpointed the problem to be the plug in. This avoids sendingg everyone on a wild goose chase. Also, give us some more information. Leaving out the version of WordPress and the name of plug in doesnt help us.

    db.php is W3 caches database module. I just downloaded the current version of W3 cache and there is no line 54 of code that correlates to your problem. This tells me that db.php is being included programatically twice.

    It is best at this point that you reinstall. Why I say this is because W3 is running on WordPress websites around the world and it is running just fine (including several of mine).

    Do this:

    1) Deactivate the W3 cache plugin.
    2) Delete W3 cache plugin
    3) Visit your website. Does the problem happen? If not, its the plug in.
    4) Upgrade to the newest version of WordPress
    5) Install the newest version of W3 cache plug in and activate it

    If it doesnt work at this point, I dont know what to tell you.

  5. karenratte
    Member
    Posted 2 years ago #

    thank you for replying to my rant.
    To make things short, I am really looking to find out if this is a WordPress core file. I think it odd that any plugin would put a file in wp-content root. IF it is not a core file then I will just delete it.
    I will search wordpress to see if I can find a file structure.

    I had already deactivated all the plugins and reactivated them. I had to rename the db.php. IF W3 is the plugin that uses this plugin then it is not part of a wordpress installation? I find it odd that This one lives in the root of wp-content. Should it not live in the W3 plugin directory? There is another plugin, dbcache that I installed that may also use this file.
    I am on the latest wordpress.

  6. karenratte
    Member
    Posted 2 years ago #

    To finalize for anyone having this problem. it appears that there are at least two plugins that copy this db.php file to the wp-content directory. DB Cache is an outdated plugin.
    @kobashicomputing.. thanks again.

  7. kobashicomputing
    Member
    Posted 2 years ago #

    You never told us that you were using DB Cache. This had nothing to do with W3 Total Cache.

    Now one look at DB Cache's compatability section should have told you not to install this plugin (0.6) because it is only good up to WordPress version 1.27. Also, the installation instructions to DBCache spoke of db.php which would have clued you in.

    To look more into the problem, I tested this on a clean install with current version of WordPress 3.2.1 and DB Cache 0.6. What I found was this:

    A) After enabling the cache, db.php shows up in the wp-content folder. db-module.php (part of DB Cache) gets copied as db.php. db-module is an copy of the core file wp-db.php. All are of the same version (0.71).

    B) After ticking the enable cache checkbox, I proceeded to get errors everywhere I attempted to navigate within the WordPress dashboard. Namely, this error prevented use of admin and at this point was hosed:

    "Fatal error: Cannot redeclare class wpdb in C:\wamp\www\iwordpress.com\wp-content\db.php on line 54"

    Developers:

    This problem is being caused due to a conflict in the naming of the database driver class. In require_wp_db(), wp-db.php is loaded and if db.php exists, db.php is loaded as well. But because both files declare a wpdb class, this error occurs. Developer needs to create a different class name and rewrite code to fix this bug.

  8. karenratte
    Member
    Posted 2 years ago #

    yep.. Sorry.. this is all new to me. but I am a learning being and you have been very helpful. I did not even realize that this initially.
    I will do better in the future, and if our paths meet, I hope I can live up to your expectations.
    thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.