Title: Error saving attachment to database
Last modified: August 18, 2016

---

# Error saving attachment to database

 *  [shadowxj5](https://wordpress.org/support/users/shadowxj5/)
 * (@shadowxj5)
 * [20 years ago](https://wordpress.org/support/topic/error-saving-attachment-to-database/)
 * I have recently installed WordPress 2.0.3, but I am unable to upload images to
   a post, pokeing around the code and stopping the inline uploading form displaying,
   allowed me to see the errors I was getting:
 * `
    WordPress database error: [Field 'post_content_filtered' doesn't have a default
   value] INSERT INTO tbg_posts (post_author, post_date, post_date_gmt, post_content,
   post_title, post_excerpt, post_status, comment_status, ping_status, post_password,
   post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order,
   post_mime_type, guid) VALUES ('2', '2006-06-13 00:49:42', '2006-06-12 23:49:42','','
   whatistbg110.jpg', '', 'attachment', 'open', 'open', '', 'whatistbg110jpg', '','','
   2006-06-13 00:49:42', '2006-06-12 23:49:42', '1', '0', 'image/jpeg', 'http://
   localhost/tBG/wp-content/uploads/2006/06/whatistbg110.jpg')   WordPress database
   error: [You have an error in your SQL syntax; check the manual that corresponds
   to your MySQL server version for the right syntax to use near '' at line 3] SELECT
   category_id FROM tbg_post2cat WHERE post_id =    WordPress database error: [You
   have an error in your SQL syntax; check the manual that corresponds to your MySQL
   server version for the right syntax to use near ' 1)' at line 2] INSERT INTO 
   tbg_post2cat (post_id, category_id) VALUES (, 1)   WordPress database error: [
   Out of range value adjusted for column 'post_id' at row 1] INSERT INTO tbg_postmeta(
   post_id,meta_key,meta_value) VALUES ('','_wp_attached_file','c:InetpubwwwroottBG/
   wp-content/uploads/2006/06/whatistbg110.jpg')
 * The last few errors are a result of the first error where the fuction wp_insert_attachment
   isn’t returning any postid due to the mysql error.
 * “[Field ‘post_content_filtered’ doesn’t have a default value]” – this field is
   a text/blob type it can’t have a default value, mysql will not allow it.
 * (I tried anyway…)
    ` #1101 - BLOB/TEXT column 'post_content_filtered' can't have
   a default value
 * When I try and insert a row into this table via mysql, I do not get any problems.
   I only get the error noted above from within WordPress.
 * Now I’m stuck as to what the problem is, any help would be appericated.
 * Platform: Windows XP Pro using its built in IIS5.5
    PHP Version: 5.1.4 Mysql 
   Build: 5.0.21-community-nt

Viewing 1 replies (of 1 total)

 *  [paradox_wp](https://wordpress.org/support/users/paradox_wp/)
 * (@paradox_wp)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/error-saving-attachment-to-database/#post-403947)
 * Hello Shadowxj5
 * I did have the same problem, seems to be how WordPress creates the fields in 
   MySQL 5. It seems to be a bug in WordPress.
 * It’s the database structure, that causes the problem, when it is initially created
   by WordPress. You need to alter the table structure once.
 * Found it on a similar thread here:
    [http://wordpress.org/support/topic/49232](http://wordpress.org/support/topic/49232)
 * **Solution:**
    enable “`Allow Nulls`” for three fields in the database. The fields
   are in table “`wp_posts`“: – `to_ping` – `pinged` – `post_content_filtered` (
   I think for your problem, it’s only the last one).
 * To do that, you need to alter the database. You can do it with the MySQL Command
   Line, but I preferred the MySQL Administrator graphical tool. So how to do that:
 * – Open MySQL Administrator
    – Connect to your database server (localhost?) – 
   Select `Catalogs` – Select your database (`wordpress`?) – Select table “`wp_posts`“–
   Select “`Edit table`” below – Unselect the tickmark at column “`Not Null`” for
   the three fields – Select “`Apply Changes`“
 * When using text mode, this also should work, but is untested!
 * `mysql -u root -p wordpress`
 * `ALTER TABLE wp_posts MODIFY COLUMN to_ping TEXT CHARACTER SET latin1 COLLATE
   latin1_bin, MODIFY COLUMN pinged TEXT CHARACTER SET latin1 COLLATE latin1_bin,
   MODIFY COLUMN post_content_filtered TEXT CHARACTER SET latin1 COLLATE latin1_bin;`

Viewing 1 replies (of 1 total)

The topic ‘Error saving attachment to database’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [paradox_wp](https://wordpress.org/support/users/paradox_wp/)
 * Last activity: [19 years, 10 months ago](https://wordpress.org/support/topic/error-saving-attachment-to-database/#post-403947)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
