Title: Deactivate/reactivate
Last modified: August 24, 2016

---

# Deactivate/reactivate

 *  [ChrisRR](https://wordpress.org/support/users/chrisrr/)
 * (@chrisrr)
 * [11 years ago](https://wordpress.org/support/topic/deactivatereactivate/)
 * Hi,
 * The WP Knowledgebase plugin looks good and does exactly what we need. However
   when we deactivate it and reactivate it (for example when updating WP) we get
   this error:
 * >> WordPress database error: [Duplicate entry ‘kbe_plugin_slug’ for key ‘option_name’]
   
   >> INSERT INTO `wp_options` (`option_name`, `option_value`) VALUES (‘kbe_plugin_slug’,‘
   knowledgebase’)
 * The only way to get WP Knowledgebase working again is to delete it from the WP
   interface and then manually re-install and reactivate. A problem with this is
   that all KB posts are then deleted on uninstall.
 * Looking at the code, the part that is causing this problem is in index.php:
 *     ```
       $kbe_optSlugSql = "Select * From ".$kbe_pre."options Where option_name like '%kbe_plugin_slug%'";
       $kbe_optSlugQry = mysql_query($kbe_optSlugSql);
       $kbe_optSlugNum = mysql_num_rows($kbe_optSlugQry);
   
       if ($kbe_optSlugNum == 0){ ..
       ```
   
 * As far as I can see $kbe_optSlugNum is always 0, even if there is a row in the
   DB meeting the query criteria. Digging further, I think the underlying error 
   generated is that “Access denied for user ”@’localhost’ (using password: NO)”.
 * If I change it to:
 *     ```
       $res = $wpdb->query($kbe_optSlugSql);
       if ($res == 0) { ...
       ```
   
 * then it seems to work. (The error is then moved to the next query using mysql_query().)
 * So I *think* (but am not sure) that mysql_query() does not use the right DB connection
   credentials, but using the WP $wpdb instance does.
 * There is a mixture of these two ways of accessing the DB in the WP Knowledgebase,
   and as far as I can see using the WPDB class is recommended in WP. Also mysql_query()
   is now deprecated. So are you thinking of updating the plugin code and removing
   mysql_…() calls?
 * Thanks,
 * Chris
 * [https://wordpress.org/plugins/wp-knowledgebase/](https://wordpress.org/plugins/wp-knowledgebase/)

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Maeve Lander](https://wordpress.org/support/users/enigmaweb/)
 * (@enigmaweb)
 * [11 years ago](https://wordpress.org/support/topic/deactivatereactivate/#post-6049770)
 * Thanks for reporting this Chris, and for helping out by sharing your solution.
   Very much appreciated. I’ll go through this and implement to the plugin for everyone
   in next release.
 * Thanks again – I really appreciate your contribution.
 * Maeve

Viewing 1 replies (of 1 total)

The topic ‘Deactivate/reactivate’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-knowledgebase_c56559.svg)
 * [WordPress Knowledge base & Documentation Plugin - WP Knowledgebase](https://wordpress.org/plugins/wp-knowledgebase/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-knowledgebase/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-knowledgebase/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-knowledgebase/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-knowledgebase/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-knowledgebase/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Maeve Lander](https://wordpress.org/support/users/enigmaweb/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/deactivatereactivate/#post-6049770)
 * Status: not resolved