Title: Database error: inserting category values
Last modified: August 18, 2016

---

# Database error: inserting category values

 *  [prara](https://wordpress.org/support/users/prara/)
 * (@prara)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/database-error-inserting-category-values/)
 * Is this the place to post bugs?
    I think this is a bug. Comes out when I create
   a subcategory with the same name as a mother category. For example: I have a 
   mother category called Poetry I created a subcategory under My Readings called
   Poetry. Seems that it tries to insert the value in the same location with the
   mother category called Poetry. I’m not sure though, here is the error log: Database
   error: [Duplicate entry ‘Poetry’ for key 2] INSERT INTO wp_categories (cat_ID,
   cat_name, category_nicename, category_description, category_parent) VALUES (‘
   0’, ‘Poetry’, ‘poetry’, ”, ‘7’) Warning: Cannot modify header information – headers
   already sent by (output started at /home/premrara/public_html/wp-includes/wp-
   db.php:80) in /home/premrara/public_html/wp-admin/categories.php on line 56

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

 *  [carthik](https://wordpress.org/support/users/carthik/)
 * (@carthik)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/database-error-inserting-category-values/#post-53621)
 * prara, as of now there can’t be two categories with the same name, regardless
   of where they are (nested / not nested).
    A workaround I found to this problem
   is to have a leading space before the second category you create with the same
   name . Like you have “poetry” and then ” poetry”.
 *  Thread Starter [prara](https://wordpress.org/support/users/prara/)
 * (@prara)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/database-error-inserting-category-values/#post-53682)
 * OK thank you but I am not doing that it’s not pretty.
 *  [samwilson](https://wordpress.org/support/users/samwilson/)
 * (@samwilson)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/database-error-inserting-category-values/#post-54135)
 * I’m getting this duplicate key error with version 1.5.2. I found [this bug ticket](http://trac.wordpress.org/ticket/240)
   on Trac which says that it’s fixed. But it isn’t. To fix it, you have to run 
   the below SQL on your database. Use PhpMyAdmin or whatever.
 * `
    ALTER TABLE $wpdb->categories DROP INDEX cat_name, ADD UNIQUE cat_name (cat_name,
   category_parent);
 * And I agree with prara, putting spaces before category names is _not_ pretty!
   🙂

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

The topic ‘Database error: inserting category values’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [samwilson](https://wordpress.org/support/users/samwilson/)
 * Last activity: [20 years, 4 months ago](https://wordpress.org/support/topic/database-error-inserting-category-values/#post-54135)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
