Title: Edit Comments SQL Error
Last modified: January 20, 2017

---

# Edit Comments SQL Error

 *  [chuckg](https://wordpress.org/support/users/chuckg/)
 * (@chuckg)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/edit-comments-sql-error/)
 * When I attempt to edit comments in 1.2 that contain quotes, notably single quotes(‘)
   but also in the case of double usage of double quotes (“), the current build 
   does not handle them well and fails the SQL command sending a flurry of errors.
   The errors are as follows:
 * > 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 ‘
   > m proud to announce the new and improved, Word/Image Count Plug]
   >  UPDATE wp_comments
   > SET comment_content = ‘WordCount “I’m proud to announce the new and improved,
   > Word/Image Count Plug-In for WordPress 1.2.” Four steps.’, comment_author =‘
   > Photo Matt’, comment_author_email = ”, comment_author_url = ‘[http://photomatt.net/archives/2004/05/24/wordcount/&#8217](http://photomatt.net/archives/2004/05/24/wordcount/&#8217);
   > WHERE comment_ID = 91 Warning: Cannot modify header information – headers already
   > sent by (output started at /var/www/wp/wp-includes/wp-db.php:80) in /var/www/
   > wp/wp-admin/post.php on line 707
 * I realize that the second error is a result of the first, so we’ll ignore that
   for now. Being a nosey little boy, I went ahead and delved into the problem and
   came out with what I believe is a simple solution. Since the error is indeed 
   within post.php, we’ll be looking at the following lines (693-703):
    ` $content
   = balanceTags($content); $content = format_to_post($content); $result = $wpdb-
   >query(" UPDATE $tablecomments SET comment_content = $content, comment_author
   = '$newcomment_author', comment_author_email = '$newcomment_author_email', comment_author_url
   = '$newcomment_author_url'".$datemodif." WHERE comment_ID = $comment_ID" );  
   If you’ll note, $content at no time has any of it’s quotes “niceified”. I propose
   that you add the following line right above the $result:  $content = balanceTags(
   $content); $content = format_to_post($content); $content = addslashes($content);
   For me, this fixed the error in it’s entirety. Since the system already handles
   dropping the slashes when the comment is displayed, it seemed the viable solution.
   Let me know.

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

 *  [hades](https://wordpress.org/support/users/hades/)
 * (@hades)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/edit-comments-sql-error/#post-56366)
 * I’d come up against the same problem, and solved it the same way. I thought it
   must be a problem in format_to_post() somehow, but that doesn’t appear to actually
   _do_ anything. Should the addslashes call go there, maybe?
    Why are edited posts
   getting slashes added, but not comments?
 *  [jbent](https://wordpress.org/support/users/jbent/)
 * (@jbent)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/edit-comments-sql-error/#post-56413)
 * Thanks, chuckg. That took care of the problem for me. Hopefully this can be corrected
   in future versions.

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

The topic ‘Edit Comments SQL Error’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [jbent](https://wordpress.org/support/users/jbent/)
 * Last activity: [21 years, 10 months ago](https://wordpress.org/support/topic/edit-comments-sql-error/#post-56413)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
