• 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 = ‘https://photomatt.net/archives/2004/05/24/wordcount/’ 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)
  • 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?

    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.