WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Fatal Error: Call to undefined function dbDelta()

[Resolved] Fatal Error: Call to undefined function dbDelta()

Viewing 7 replies - 1 through 7 (of 7 total)
  • This issue seems to be a common one when using alternative databases. For me, it was resolved by this:

    Find dbDelta($sql); in plugin file “index.php” and replace it with

    //dbDelta($sql);
    $wpdb->query($sql);

    The solution was found here: http://html5.svnlabs.com/faqs/fatal-error-call-to-undefined-function-dbdelta-in-wp-contentpluginshtml5-video-player-with-playlistindex-php-on-line-211/

    An alternative option is to try:

    //dbDelta($sql);
    mysql_query($sql);

    WebTechGlobal
    Participant

    @webtechglobal

    dbDelta() does not just execute a CREATE query. It also updates existing tables.

    I found this post as I’ve started to get the same issue in WP e-Customers. dbDelta() is called within a class method which is used in the method that the activation hook calls.

    I made changes. I moved dbDelta() for about six tables into a create_tables() function. Previously they sat in the function called directly by the activation hook. I’ll be surprised if it is the cause but it is the only change I made.

    WebTechGlobal
    Participant

    @webtechglobal

    This is required. I’ve just forgotten to move it with everything else. Actually whenever your working in a plugin and you get a function undefined error. It usually because the plugin needs to include it.

    require_once( ABSPATH . ‘wp-admin/includes/upgrade.php’ );

    Hi everyone, hope we are all doing well.
    I have been working on a site, and upon trying to activate a plugin, I was faced with this error

    error: Call to undefined function dbDelta() in xxxxxxxxxxxxx/wp-content/plugins/purple-xmls/purple-xmls-setup.php on line 16

    I was wondering if anybody knew the best way to resolve this issue.

    thank you kindly for your time
    Tanya

    WebTechGlobal
    Participant

    @webtechglobal

    Try adding this…

    require( ABSPATH . ‘wp-admin/includes/upgrade.php’ );

    Thank you kindly my friend. Which file would I be applying the change to?

    WebTechGlobal
    Participant

    @webtechglobal

    You can add the line anywhere before the dbDelta() function. I’d be surprised if the error is WordPress core itself, probably a plugin. However if there is a missing file or customizing to the core it is possible.

    The dbDelta() function creates database tables. If a plugin is attempting to create a table you need to either place that line somewhere in the plugins files or disable the plugin until it is fixed.

    If you cannot access your blog at all. Use FTP to access the wp-content/plugins directory and delete all plugins. Remembering to back em all up first.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Fatal Error: Call to undefined function dbDelta()’ is closed to new replies.