WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] mysql errors with wp-mail after upgrade to 1.5.1.3 from 1.5.1.2 (25 posts)

  1. Tremaine
    Member
    Posted 9 years ago #

    I just upgraded WP 1.5.1.2 to 1.5.1.3 (after backing up the entire directory and mysql db of course!) and can no longer post via email to my blog at http://blog.ddiction.com/

    I get the following errors when going using wp-mail.php

    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 a very odd experience to see your arm and hand responding co]
    INSERT INTO wp_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 ('3', '2005-07-09 20:28:57', '2005-07-10 03:28:57', '2005-07-09 20:28:57', '2005-07-10 03:28:57', '

    This is then followed by the content of the email post, then followed by more errors

    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 wp_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 wp_post2cat (post_id, category_id) VALUES (, 1)

    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 1]
    SELECT pinged FROM wp_posts WHERE ID =

    Any mysql gurus out there know what's happening here and how I can fix it? I can still post normally from within the admin interface, but I use the wp-mail function because I post to multiple places at the same time via email.

  2. Tremaine
    Member
    Posted 9 years ago #

    Ok... I have no idea what just happened, but I sent a test message to my blogs email address... and it posted with no errors at all.

    I suppose my mail client (Evolution) may have sent the original message with errors... Bizarre.

  3. Tremaine
    Member
    Posted 9 years ago #

    It appears this is going to be an ongoing and intermittent problem. I made another post with substantive content (rather than a single line test post) via email and the error recurred.

  4. faithintsu
    Member
    Posted 8 years ago #

    Did you ever get this fixed? As I am having the same issue on the Blog on run, its giving me the same output. I am running MySQL 4.1

  5. faithintsu
    Member
    Posted 8 years ago #

    I did a complete re-install of my WordPress thinking it might be an issue with the actual MySQL Version, but still receiving the same error on posting from an e-mail source.

  6. Tremaine
    Member
    Posted 8 years ago #

    Still unresolved unfortunately... it's annoying as hell.

  7. Tremaine
    Member
    Posted 8 years ago #

    Any WordPress gurus out here watching this thread at all? I have root access on the server this is occurring on and I'd be happy to provide service versions and enable debugging to help track this sucker down.

    Apache/2.0.54
    PHP 4.4.0 (cli)
    Zend Engine v1.3.0
    mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (i686)

    from mysql.log when going using wp-mail.php (edited to remove email addresses)


    2 Init DB blog-ddiction
    2 Query SELECT * FROM wp_users WHERE user_level > 0
    050724 18:57:43 2 Query SELECT option_name, option_value FROM wp_options WHERE autol oad = 'yes'
    1 Query SELECT username, crypt, "", uid, gid, pop, "", "", realname, "" FROM users WHERE username = "removed"
    2 Query SELECT ID FROM wp_users WHERE user_email='removed ' ORDER BY ID DESC LIMIT 1
    2 Query SELECT option_value FROM wp_options WHERE option_name = 'sub jectprefix'
    2 Query SELECT post_name FROM wp_posts WHERE post_name = 'cuz-im-a-m eme-whore-and-my-brain-is-fried-from-working-over-the' AND post_status = 'publish' AND ID != '' LIMIT 1
    2 Query INSERT INTO wp_posts
    (post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_c ontent, post_title, post_excerpt, post_category, post_status, post_name, comment_status, ping_st atus, post_parent)
    VALUES ('3', '2005-07-24 17:43:11', '2005-07-25 00:43:11', '2005-07-24 17:43:11' , '2005-07-25 00:43:11', 'Congratulations on being the creator of a new
    Evil Plan (tm)!
    Your objective is simple: World Domination.

    Your motive is a little bit more complex: Power

    Stage One
    To begin your plan, you must first assassinate a pope. This will
    cause the world to whisper among themselves, alarmed by your
    arrival. Who is this despoiler of all that is good and nice and
    true? Where did they come from? And why do they look so good in
    a corporate suit?

    Stage Two
    Next, you must seize control of the Internet. This will all be
    done from a obsidian citadel, a mysterious place of unrivaled
    dark glory. Upon seeing this, the world will gibber like madmen,
    as countless hordes of computer programmers hasten to do your
    every bidding.

    Stage Three
    Finally, you must prepare your corporate takeover, bringing
    about a 1984 police state. Your name shall become synonymous
    with fear, and no man will ever again dare cross you. Everyone
    will bow before your cunning intelligence, and the world will
    have no choice but to whisper your name in fear.', 'Cuz I'm a meme whore, and my brain i s fried from working over the', '', '1', 'publish', 'cuz-im-a-meme-whore-and-my-brain-is-fried-f rom-working-over-the', 'open', 'open', '0')
    2 Query UPDATE wp_posts SET guid = 'http://blog.ddiction.com/?p=' WH ERE ID = ''
    2 Query SELECT category_id
    FROM wp_post2cat
    WHERE post_id =
    2 Query INSERT INTO wp_post2cat (post_id, category_id)
    VALUES (, 1)

    If there is anything else I can provide that would help troubleshoot this, let me know.

  8. Tremaine
    Member
    Posted 8 years ago #

    To provide some comparison, when posting via the web interface the mysql.log shows this. Same content as from the email post that failed.


    2 Init DB blog-ddiction
    2 Query SELECT * FROM wp_users WHERE user_level > 0
    2 Query SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
    2 Query SELECT ID, user_login, user_pass FROM wp_users WHERE user_login = 'admin'
    2 Query SELECT * FROM wp_categories
    2 Query SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '0'
    2 Query SHOW TABLE STATUS LIKE 'wp_posts'
    2 Query SELECT post_name FROM wp_posts WHERE post_name = 'cuz-im-a-meme-whore-and-my-brain-is-fried-from-working-over-the-weekend' AND post_status = 'publish' AND ID != '943' LIMIT 1
    2 Query INSERT INTO wp_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
    ('943', '1', '2005-07-24 18:08:33', '2005-07-25 01:08:33', 'Congratulations on being the creator of a new
    Evil Plan (tm)!
    Your objective is simple: World Domination.

    Your motive is a little bit more complex: Power

    Stage One
    To begin your plan, you must first assassinate a pope. This will
    cause the world to whisper among themselves, alarmed by your
    arrival. Who is this despoiler of all that is good and nice and
    true? Where did they come from? And why do they look so good in
    a corporate suit?

    Stage Two
    Next, you must seize control of the Internet. This will all be
    done from a obsidian citadel, a mysterious place of unrivaled
    dark glory. Upon seeing this, the world will gibber like madmen,
    as countless hordes of computer programmers hasten to do your
    every bidding.

    Stage Three
    Finally, you must prepare your corporate takeover, bringing
    about a 1984 police state. Your name shall become synonymous
    with fear, and no man will ever again dare cross you. Everyone
    will bow before your cunning intelligence, and the world will
    have no choice but to whisper your name in fear. ', 'Cuz I\'m a meme whore, and my brain is fried from working over the weekend', '', 'publish', 'open', 'open', '', 'cuz-im-a-meme-whore-and-my-brain-is-fried-from-working-over-the-weekend', '', '2005-07-24 18:08:33', '2005-07-25 01:08:33', '0', '0')
    2 Query SELECT * FROM wp_post2cat WHERE post_id = 943 AND category_id = 1
    2 Query INSERT INTO wp_post2cat
    (post_id, category_id)
    VALUES
    (943, 1)
    2 Query SELECT * FROM wp_posts WHERE ID=943
    2 Query UPDATE wp_posts SET guid = 'http://blog.ddiction.com/?p=943' WHERE ID = '943'
    050724 19:08:35 3 Connect username@localhost on
    3 Init DB blog-ddiction
    3 Query SELECT * FROM wp_users WHERE user_level > 0
    3 Query SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
    3 Query SELECT * FROM wp_categories
    3 Query SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 3 AND post_status != 'draft' AND post_status != 'static') GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
    3 Query SELECT DISTINCT
    post_id, cat_ID FROM wp_categories, wp_post2cat
    WHERE category_id = cat_ID AND post_id IN (943,942,941,939,938,937,936,935,934,933)
    3 Query SELECT ID, COUNT( comment_ID ) AS ccount
    FROM wp_posts
    LEFT JOIN wp_comments ON ( comment_post_ID = ID AND comment_approved = '1')
    WHERE ID IN (943,942,941,939,938,937,936,935,934,933)
    GROUP BY ID
    3 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN(943,942,941,939,938,937,936,935,934,933) ORDER BY post_id, meta_key
    3 Query SELECT DISTINCT YEAR(post_date) AS
    year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:35' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    050724 19:08:36 3 Query SELECT * FROM wp_posts WHERE post_status = 'static' ORDER BY post_title ASC
    3 Query SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:36' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    3 Query SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
    FROM wp_categories
    WHERE cat_ID > 0
    ORDER BY cat_id asc
    3 Query SELECT cat_ID,
    COUNT(wp_post2cat.post_id) AS cat_count
    FROM wp_categories
    INNER JOIN wp_post2cat ON (cat_ID = category_id)
    INNER JOIN wp_posts ON (ID = post_id)
    WHERE post_status = 'publish'
    AND post_date_gmt < '2005-07-25 01:08:36'
    GROUP BY category_id
    3 Query SELECT option_value FROM wp_options WHERE option_name = 'blogfilename'
    3 Query SELECT cat_id, cat_name, auto_toggle, show_images, show_description, show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit FROM wp_linkcategories WHERE cat_id=1
    3 Query SELECT link_url, link_name, link_image, link_target,
    link_description, link_rating, link_rel , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated , UNIX_TIMESTAMP(link_updated) AS link_updated_f
    FROM wp_links
    WHERE link_visible = 'Y' AND link_category = 1 ORDER BY rand() ASC
    3 Query SELECT COUNT(ID) FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 3 AND post_status != 'draft' AND post_status != 'static')
    3 Quit
    050724 19:08:49 1 Query SELECT username, crypt, "", uid, gid, pop, "", "", realname, "" FROM users WHERE username = "hcarrigan@allcan.com"
    4 Connect username@localhost on
    4 Init DB blog-ddiction
    4 Query SELECT * FROM wp_users WHERE user_level > 0
    4 Query SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
    4 Query SELECT * FROM wp_categories
    4 Query SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
    4 Query SELECT DISTINCT
    post_id, cat_ID FROM wp_categories, wp_post2cat
    WHERE category_id = cat_ID AND post_id IN (943,942,941,939,938,937,936,935,934,933)
    4 Query SELECT ID, COUNT( comment_ID ) AS ccount
    FROM wp_posts
    LEFT JOIN wp_comments ON ( comment_post_ID = ID AND comment_approved = '1')
    WHERE ID IN (943,942,941,939,938,937,936,935,934,933)
    GROUP BY ID
    4 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN(943,942,941,939,938,937,936,935,934,933) ORDER BY post_id, meta_key
    4 Query SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:49' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    4 Query SELECT * FROM wp_posts WHERE post_status = 'static' ORDER BY post_title ASC
    4 Query SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:49' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    4 Query SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
    FROM wp_categories
    WHERE cat_ID > 0
    ORDER BY cat_id asc
    4 Query SELECT cat_ID,
    COUNT(wp_post2cat.post_id) AS cat_count
    FROM wp_categories
    INNER JOIN wp_post2cat ON (cat_ID = category_id)
    INNER JOIN wp_posts ON (ID = post_id)
    WHERE post_status = 'publish'
    AND post_date_gmt < '2005-07-25 01:08:49'
    GROUP BY category_id
    4 Query SELECT option_value FROM wp_options WHERE option_name = 'blogfilename'
    4 Query SELECT cat_id, cat_name, auto_toggle, show_images, show_description, show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit FROM wp_linkcategories WHERE cat_id=1
    4 Query SELECT link_url, link_name, link_image, link_target,
    link_description, link_rating, link_rel , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated , UNIX_TIMESTAMP(link_updated) AS link_updated_f
    FROM wp_links
    WHERE link_visible = 'Y' AND link_category = 1 ORDER BY rand() ASC
    4 Query SELECT COUNT(ID) FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static')
    4 Quit
    050724 19:08:52 5 Connect username@localhost on
    5 Init DB blog-ddiction
    5 Query SELECT * FROM wp_users WHERE user_level > 0
    5 Query SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
    5 Query SELECT * FROM wp_categories
    5 Query SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 3 AND post_status != 'draft' AND post_status != 'static') GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
    5 Query SELECT DISTINCT
    post_id, cat_ID FROM wp_categories, wp_post2cat
    WHERE category_id = cat_ID AND post_id IN (943,942,941,939,938,937,936,935,934,933)
    5 Query SELECT ID, COUNT( comment_ID ) AS ccount
    FROM wp_posts
    LEFT JOIN wp_comments ON ( comment_post_ID = ID AND comment_approved = '1')
    WHERE ID IN (943,942,941,939,938,937,936,935,934,933)
    GROUP BY ID
    5 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN(943,942,941,939,938,937,936,935,934,933) ORDER BY post_id, meta_key
    5 Query SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:52' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    050724 19:08:53 5 Query SELECT * FROM wp_posts WHERE post_status = 'static' ORDER BY post_title ASC
    5 Query SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_date < '2005-07-24 18:08:53' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
    5 Query SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
    FROM wp_categories
    WHERE cat_ID > 0
    ORDER BY cat_id asc
    5 Query SELECT cat_ID,
    COUNT(wp_post2cat.post_id) AS cat_count
    FROM wp_categories
    INNER JOIN wp_post2cat ON (cat_ID = category_id)
    INNER JOIN wp_posts ON (ID = post_id)
    WHERE post_status = 'publish'
    AND post_date_gmt < '2005-07-25 01:08:53'
    GROUP BY category_id
    5 Query SELECT option_value FROM wp_options WHERE option_name = 'blogfilename'
    5 Query SELECT cat_id, cat_name, auto_toggle, show_images, show_description, show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit FROM wp_linkcategories WHERE cat_id=1
    5 Query SELECT link_url, link_name, link_image, link_target,
    link_description, link_rating, link_rel , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated , UNIX_TIMESTAMP(link_updated) AS link_updated_f
    FROM wp_links
    WHERE link_visible = 'Y' AND link_category = 1 ORDER BY rand() ASC
    5 Query SELECT COUNT(ID) FROM wp_posts WHERE 1=1 AND post_date_gmt <= '2005-07-25 01:08:59' AND (post_status = "publish" OR post_author = 3 AND post_status != 'draft' AND post_status != 'static')
    5 Quit

  9. Tremaine
    Member
    Posted 8 years ago #

    Ok, more information to add to this whole mess. I've been firing a pile of test messages to my blog via email with different criteria.

    It appears that the existence of a single apostrophe in the message or subject will break it.

    Email length and subject line length doesn't matter.

    Now if only I knew enough about php and mysql to actually fix the problem.

  10. faithintsu
    Member
    Posted 8 years ago #

    I tried it with and without the apostrophe and it is still dumping my post from the e-mail. I really hope a WordPress Delveoper is taking a look at this thread, as I really need a fix on this. Can someone please take a look here?

  11. faithintsu
    Member
    Posted 8 years ago #

    Bumping this again for maybe a WordPress Guru to take a look at it.

  12. Tremaine
    Member
    Posted 8 years ago #

    I've created a ticket over here -> http://trac.wordpress.org/ticket/1536 to track this issue as well. Perhaps if a others chime in with bug reports we can get this looked at.

  13. Tremaine
    Member
    Posted 8 years ago #

    Giving this a half hearted bump as it appears noone who can help is watching either this thread, or the open bug ticket on it.

  14. Mark Jaquith
    WordPress Lead Dev
    Posted 8 years ago #

    Bumped your bug report up for the devs to see. Seems like an issue of the content just not being escaped.

    As a temporary fix for you, try adding this in a plugin (or at the top of wp-mail.php):


    add_filter('phone_content', 'addslashes');

  15. faithintsu
    Member
    Posted 8 years ago #

    I added this line at the very top of the code and am still getting an error message now when attempting to call this script from a browser:

    Fatal error: Call to undefined function: add_filter() in /home/murphy/public_html/mind/wp-mail.php on line 2

  16. skippy
    Member
    Posted 8 years ago #

    Make sure the add_filter line occurs after this:
    require(dirname(__FILE__) . '/wp-config.php');

  17. faithintsu
    Member
    Posted 8 years ago #

    That seemed to fix it - just not parsing the HTML correctky, but i can live with it.

    Thanks a Million!!

  18. faithintsu
    Member
    Posted 8 years ago #

    Well - how great is this, upgrading to versi 1.5.2 breaks the configuration change. I have no clue why this was not bundled into the software, but it wasn't. So after upgrading having to go back in and make the change.

    Any reason it was not added?

  19. skippy
    Member
    Posted 8 years ago #

    Simple oversight, most likely. The milestone set on the ticket is 1.6. Version 1.5.2 was kind of an unexpected release specifically to fix a security problem. We were able to include a handful of feature enhancements into it, but we obviously didn't reflag every ticket from a 1.6 milestone to 1.5.2.

    This fix ought to be bundled into 1.6, whenever that is released.

  20. tbhimdi
    Member
    Posted 8 years ago #

    The addfilter... line does work, fixing apostrophe crashes if there is one in the body, thanks.

    The post still breaks if there is an apostrophe in the subject line though, you have to manually escape it.

    I'm using the addfilter line along with this patch:
    http://trac.wordpress.org/ticket/1515

    Maybe they don't work together so well? Or maybe they do and the addfilter doesn't work on subject lines, no clue. I haven't tried an apostrophe post without the above 1515 since my phone post requires the 1515 patch as well.

  21. jwurster
    Member
    Posted 8 years ago #

    I was having the same problems with the apostrophe in the Subject line or email content. So, I looked for another plugin and found Postoe, which I couldn't get to work.

    I just tried the fix in ticket #1515 but it still didn't like the apostrophe in the email content.

    I'll try a couple more tests.

  22. tbhimdi
    Member
    Posted 8 years ago #

    Well #1515 is just for fixing the subject line, it has nothing to do with apostrophes, only reason I mentioned it was because I didn't test add_filter without it.

    Here is the add_filter ticket: http://trac.wordpress.org/ticket/1536

    It fixes all apostrophe problems for me in the email content, just make sure to manually escape apostrophes in the subject line.

  23. jwurster
    Member
    Posted 8 years ago #

    Thanks for the information. I'm using wp-cron and its wp-cron-mail plugin. It had the same problem but Skippy helped me modify the wp-cron-mail.php in a similar fashion except using addslashes(). Bottomline, it works.

    Now I'm working with the Postie plugin author to figure out how to eliminate the email formatting problems I have in the post.

    Thanks again skippy.

  24. skippy
    Member
    Posted 8 years ago #

    Alternately, add this to wp-mail.php to correctly handle apostrophes in the subject:
    $subject = addslashes($subject[0]);

    In a stock wp-mail.php, that should replace the contents of line 58.

  25. tbhimdi
    Member
    Posted 8 years ago #

    Perfect! Thanks skippy.

    #1515 & #1536 + $subject/addslashes all work together in harmony. All I need now is the base64 bug (#1655) fixed and I'll be in moblog heaven.

    I hope there is a bug fix 1.5.x release soon, this 1.6 wait to officially get wp-mail bugs squished is going to be a tough wait for many I think.

Topic Closed

This topic has been closed to new replies.

About this Topic