• My site, Breakfastclubber.com/42 , looks ok from the main page, but I haven’t been able to post entries with single quotes. when I post an entry without single quotes

    this is a post to see if single quotes are killing the ability to post.

    it works, but making the entry

    this is a post to see if a post’s single quotes are killing the ability to post.

    I get this

    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 ‘s single quotes are killing the ability to post.’, ‘Testing ide]
    INSERT INTO fortytwo_posts (ID, 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, post_modified, post_modified_gmt, post_parent, menu_order) VALUES (’29’, ‘1’, ‘2005-04-20 19:56:28’, ‘2005-04-21 00:56:28’, ‘this is a post to see if a post’s single quotes are killing the ability to post.’, ‘Testing idea about single quotes breaking post’, ”, ‘publish’, ‘open’, ‘open’, ”, ‘testing-idea-about-single-quotes-breaking-post-2’, ”, ‘2005-04-20 19:56:28’, ‘2005-04-21 00:56:28’, ‘0’, ‘0’)

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/41/d89530764/htdocs/root_becca/42/wp-includes/wp-db.php:98) in /homepages/41/d89530764/htdocs/root_becca/42/wp-admin/post.php on line 153

    Warning: Invalid argument supplied for foreach() in /homepages/41/d89530764/htdocs/root_becca/42/wp-admin/post.php on line 158

    it seems to cut right before the single quote, and after one later in the post. any suggestions on what I could do? now I’m just not using single quotes, but in the future it would be a good thing to be able to do.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Could be something with your character set. What charset are you using?

    Thread Starter breakfastclubber

    (@breakfastclubber)

    it just says this:
    <meta http-equiv=”Content-Type” content=”text/html; charset=<?php bloginfo(‘charset’); ?>” />

    where do I find what charset that corresponds to?

    Hm. Good question. I haven’t had any difficulties with that declaration myself, so haven’t gone looking. It sounds like a problem with the charset declaring as ISO-8859-1 somewhere within your pages (an overall index page maybe?), and the WP install looking for a UTF-8 charset.

    I could be way out in left field though…. as I said, I haven’t actually had problems with the charset declaration.

    Thread Starter breakfastclubber

    (@breakfastclubber)

    I’ve never had trouble with this either. I suppose maybe it’s a wordpress issue, or a database corruption on my server, or maybe even plugins conflicting. If this isn’t a typical thing to happen though, I suppose I’ll just have to remember to delete single quotes. Thanks for your help!

    Oh, you’re welcome, though I certainly was NOT much help. If I run across anything, I’ll post back….

    Thread Starter breakfastclubber

    (@breakfastclubber)

    ok, thanks ??

    i’m having this problem – but only when my post is submitted by email and loaded using wp-mail.php. the single quotes, it seems, are not being escaped in the sql statement used to insert the post in the database.

    mine is a new installation (90 minutes old) of 1.5.1.3.

    the problem is solved by adding the function addslashes() to the sql statement at around line 49 of functions-post.php to read:

    $sql = “INSERT INTO $wpdb->posts
    (post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name, comment_status, ping_status, post_parent)
    VALUES (‘$post_author’, ‘$post_date’, ‘$post_date_gmt’, ‘$post_date’, ‘$post_date_gmt’, ‘”.addslashes($post_content).”‘, ‘$post_title’, ‘$post_excerpt’, ‘$post_cat’, ‘$post_status’, ‘$post_name’, ‘$comment_status’, ‘$ping_status’, ‘$post_parent’)”;

    quite possibly the same problem exists in the posting of comments. but i haven’t tested that.

    I’m no expert, but something to check on: this type of thing is affected by the “magic_quotes_gpc” PHP setting, as defined in your (or your host’s) php.ini file. I believe “on” is the desired setting to properly handle quotes.

    magic_quotes_gpc affects the handling of get, post & cookie variables. on my machine the value of magic_quotes_gpc is ‘On’.

    it would not be effective in the handling of email-delivered posts (no get, post or cookie variables involved), hence the above hack. but when posts are inserted / updated using forms, all is ok.

    at least, that seems the most likely explanation for the behaviour i’ve seen. i haven’t looked too deeply into it!

    WordPress does not rely on magic_quotes_gpc. If it’s turned on, then all the slashes from $_GET, $_POST, $_COOKIE and $_SERVER are stripped. Then those four arrays have slashes added to them, regardless of whether magic_quotes_gpc is on or not. The net effect is that those four arrays get all their quotes escaped, regardless of php.ini settings.

    The problem probably would happen when using wp-mail.php.

    sadara wrote:

    the problem is solved by adding the function addslashes() to the sql statement at around line 49 of functions-post.php to read:

    Well, this solves the problem of the database error, but then, as the function would suggest, it would (did in my testing) add a slash in front of all the single quotes. This is not a solution as far as I’m concerned ??

    What I did that actually seems to have fixed the issue is to add the following bit just in front of the $sql=:
    $foo = addslashes($post_content);
    $bar = stripslashes($foo);

    And then replace $post_content in the query with $bar. Not perfect, but it works.

    Oh, and this was only an issue for me when posting from email.

    EDIT: thanks to sadara for pointing me in the right direction ??

    I have the exact same problem when trying to post via email. I’ve fuddled around with addslashes and other things in the wp-mail.php file, but the problem of single quotes in my post has persist. Thanks for the tip on the functions-post.php file.

    I’m only just now reading this thread, and I don’t find this solution all that satisfying. What determines when and when not to use addslashes throughout the WordPress php files? I’m under the impression that addslashes should be used whenever you run a query. Why don’t all the queries in these WP php files make use of the addslashes() function? Thanks, by the way, to the stellar sleuths who discovered where to stick the addslashes to resolve this particular problem. I’m just a little unsettled by it.
    David

    By the way, don’t forget to apply the solutions provided in this thread to both $post_content and $post_title. ??

    sadara

    (@sadara)

    dangcookie wrote:

    By the way, don’t forget to apply the solutions provided in this thread to both $post_content and $post_title. ??

    … and $post_excerpt!

    estjohn

    (@estjohn)

    ok i must be doing this the wrong way.. but can you not put them in backticks?

    ‘I am trying this’ (This is not in backtics)
    vs
    'I am trying this' (This is in backtics)

    oh well.. interesting enough, the backtick changed the appearance of the quote here… oh no wonder it did the font too doh!

    hmm

    I am going to have to reread this.. I must have missed something.

    Oh well just ignore me. I dont know where I missed something, but I am sure I did.. so overlook me ??

    —–I had a blonde moment——-

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Single quotes seem to not be allowed in posts’ is closed to new replies.