Title: error on error log while activating plug in
Last modified: March 11, 2024

---

# error on error log while activating plug in

 *  Resolved [dutt3684](https://wordpress.org/support/users/dutt3684/)
 * (@dutt3684)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/)
 * [11-Mar-2024 03:09:26 UTC] WordPress database error Table ‘wp_ts_redirects’ already
   exists for query RENAME TABLE ts_redirects TO wp_ts_redirects made by require(‘
   wp-blog-header.php’), wp, WP->main, do_action_ref_array(‘wp’), WP_Hook->do_action,
   WP_Hook->apply_filters, ts_redirects::redirects_301_do_redirect, Redirects->getAll,
   Redirects->checkForRedirectsTable This error shown on database while activating
   plug in — kindly let us know, what to do
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-on-error-log-while-activating-plug-in%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Alexandru Tapuleasa](https://wordpress.org/support/users/talextech/)
 * (@talextech)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/#post-17489603)
 * Hi,
 * There are a few lines of code that were meant to add the wp_ prefix to the redirects
   table as a while back the plugin didn’t add that.
 * In your case it seems like you ended up both with the unprefixed table and the
   prefixed table at the same time for some reason 🙁
 * You will need to delete the ts_redirects table from the database manually and
   leave just wp_ts_redirects
 *  Thread Starter [dutt3684](https://wordpress.org/support/users/dutt3684/)
 * (@dutt3684)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/#post-17499786)
 * Hi, Thanks for your response. I have trying finding table and find “ts-redirects.
   js” in JS folder and no other file found here with naming “wp_ts_redirects” file
   at any of file or folder, Kindly advise what to do . Below is the coding I found
   related to details given by you, Kindly make a look is this the fil you are writing
   about:–
 * <?php
   class Redirects{function delete(){global $wpdb;
 *     ```wp-block-code
       $sql = "TRUNCATE TABLE {$wpdb->prefix}ts_redirects";
       $wpdb->query($sql);
       ```
   
 * } // delete
 * function edit($title, $section, $new_link, $old_link)
   {global $wpdb;$sql = $wpdb-
   >prepare(“INSERT INTO {$wpdb->prefix}ts_redirects (title, section, new_link, 
   old_link) VALUES (%s, %s, %s, %s)”, array($title, $section, $new_link, $old_link));
   $wpdb->query($sql);} // edit
 * function getFields($id)
   {global $wpdb;
 *     ```wp-block-code
       $sql = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}ts_redirects WHERE id = %d", array($id));
       $result = $wpdb->query($sql);
       if ($result !== 0) {
         $fields = array();
         foreach ($wpdb->get_results($sql) as $row) {
           $fields['title'] = $row->title;
           $fields['section'] = $row->section;
           $fields['new_link'] = $row->new_link;
           $fields['old_link'] = $row->old_link;
         }
   
         return $fields;
       } else {
         return false;
       }
       ```
   
 * } // getFields
 * function createRedirectsTable()
   {global $wpdb;
 *     ```wp-block-code
       $sql = "CREATE TABLE {$wpdb->prefix}ts_redirects (id BIGINT(20) PRIMARY KEY AUTO_INCREMENT,title TEXT,section TEXT, new_link TEXT, old_link TEXT)";
       $wpdb->query($sql);
       ```
   
 * } // createRedirectsTable
 * function checkForRedirectsTable()
   {global $wpdb;
 *     ```wp-block-code
       $sql = "SHOW TABLES LIKE 'ts_redirects'";
       $result = $wpdb->get_results($sql);
       if (sizeof($result) == 1) {
         $wpdb->query("RENAME TABLE ts_redirects TO {$wpdb->prefix}ts_redirects");
       }
   
       $sql = "SHOW TABLES LIKE '{$wpdb->prefix}ts_redirects'";
       $result = $wpdb->get_results($sql);
       if (sizeof($result) != 1) {
         $this->createRedirectsTable();
       }
       ```
   
 * } // checkForRedirectsTable
 * function getAll()
   {global $wpdb;
 *     ```wp-block-code
       $this->checkForRedirectsTable();
   
       $sql = "SELECT * FROM {$wpdb->prefix}ts_redirects ORDER by id ASC";
       $result = $wpdb->query($sql);
       if ($result !== 0) {
   
         $id_arr = array();
         foreach ($wpdb->get_results($sql) as $row) {
           $id_arr[] = $row->id;
         }
   
         return $id_arr;
       } else {
         return false;
       }
       ```
   
 * } // getAll
 * function remove($custom_id)
   {global $wpdb;
 *     ```wp-block-code
       $sql = $wpdb->prepare("DELETE FROM {$wpdb->prefix}ts_redirects WHERE id = %d", array($custom_id));
       $wpdb->query($sql);
       ```
   
 * }
   } // remove
 * $redirectsplugin = new Redirects();
   $GLOBALS[‘redirectsplugins’] = $redirectsplugin;
    -  This reply was modified 2 years, 2 months ago by [dutt3684](https://wordpress.org/support/users/dutt3684/).
    -  This reply was modified 2 years, 2 months ago by [dutt3684](https://wordpress.org/support/users/dutt3684/).
    -  This reply was modified 2 years, 2 months ago by [dutt3684](https://wordpress.org/support/users/dutt3684/).
 *  Thread Starter [dutt3684](https://wordpress.org/support/users/dutt3684/)
 * (@dutt3684)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/#post-17502461)
 * kindly reply on this
 *  Plugin Author [Alexandru Tapuleasa](https://wordpress.org/support/users/talextech/)
 * (@talextech)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/#post-17503209)
 * I thought I did, sorry. Like my first reply says “you will need to delete the
   ts_redirects table **from the database**“.
 * It’s not a file, you need to access your database via phpMyAdmin or whatever 
   tool your host provides you with and delete it from there. Not the wp_ts_redirects
   table, just ts_redirects (without the wp_ prefix)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘error on error log while activating plug in’ is closed to new replies.

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

 * 4 replies
 * 2 participants
 * Last reply from: [Alexandru Tapuleasa](https://wordpress.org/support/users/talextech/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/error-on-error-log-while-activating-plug-in/#post-17503209)
 * Status: resolved