Title: Database error on multisite
Last modified: April 4, 2017

---

# Database error on multisite

 *  Resolved [Schweizer Solutions GmbH](https://wordpress.org/support/users/schweizersolutions/)
 * (@schweizersolutions)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/database-error-on-multisite/)
 * Hi,
 * on the multisite we become an database error in the log, because the table is
   not created for the specific blog id:
 *     ```
       [error] 24820#24820: *51548 FastCGI sent in stderr: "PHP message: WordPress-Datenbank-Fehler Table 'db.wp_93_redirects' doesn't exist für Abfrage SELECT *
                   FROM wp_93_redirects
                   WHERE status != 404 AND status != 'inactive'
                   ORDER BY id desc von require('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, EPS_Redirects->do_redirect, EPS_Redirects::get_redirects" while reading response header from upstream, client: 77.186.210.193, server: db.savviihq.com, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-fpm.db.sock:", host: "portal.example.com", referrer: "http://portal.example.com/wp-login.php"
       ```
   
 * We’ve changed the create table function, to support multisite installation:
 *     ```
       	public static function _create_redirect_table() {
       		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   
       		global $wpdb;
   
       		$blogids = array( false );
   
       		if ( is_network_admin() && is_multisite() ) {
       			$old_blog = $wpdb->blogid;
       			$blogids  = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
       		}
   
       		foreach ( $blogids as $blog_id ) {
   
       			if ( $blog_id ) {
       				switch_to_blog( $blog_id );
       			}
   
       			$table_name = $wpdb->prefix . "redirects";
   
       			$sql = "CREATE TABLE $table_name (
                 id mediumint(9) NOT NULL AUTO_INCREMENT,
                 url_from VARCHAR(256) DEFAULT '' NOT NULL,
                 url_to VARCHAR(256) DEFAULT '' NOT NULL,
                 status VARCHAR(12) DEFAULT '301' NOT NULL,
                 type VARCHAR(12) DEFAULT 'url' NOT NULL,
                 count mediumint(9) DEFAULT 0 NOT NULL,
                 UNIQUE KEY id (id)
              );";
   
       			dbDelta( $sql );
       		}
   
       		if ( $blog_id ) {
       			switch_to_blog( $old_blog );
       		}
       	}
       ```
   
 * It will be nice, if you can add multisite support to your next update.
 * Another thing is, that this plugin don’t have a uninstall.php, where the table(
   s) will be dropped, if we uninstall it. Maybe you can fix this also 😉
 * Cheers
    Andreas

The topic ‘Database error on multisite’ is closed to new replies.

 * ![](https://ps.w.org/eps-301-redirects/assets/icon-256x256.png?rev=2413221)
 * [301 Redirects - Redirect Manager](https://wordpress.org/plugins/eps-301-redirects/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/eps-301-redirects/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/eps-301-redirects/)
 * [Active Topics](https://wordpress.org/support/plugin/eps-301-redirects/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/eps-301-redirects/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/eps-301-redirects/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Schweizer Solutions GmbH](https://wordpress.org/support/users/schweizersolutions/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/database-error-on-multisite/)
 * Status: resolved