Support » Plugin: Auto Post Thumbnail » You have an error in your SQL syntax

  • Resolved j3d3s3


    I keep getting the following errors when using this plugin. Please help resolve this. It keeps repeating and fills up the log file. I am sure everyone is experiencing this.

    Error log entry:
    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 for query SELECT * FROM wp_posts WHERE
    id = made by do_action_ref_array, call_user_func_array, wpr_poster, wpr_post, wpr_insertpost, wp_insert_post, wp_transition_post_status, do_action(‘transition_post_status’), call_user_func_array, apt_check_required_transition, apt_publ

    If there is any patch work that could be done manually, please let us know.


Viewing 10 replies - 1 through 10 (of 10 total)
  • I have the same problem… a big log with this issue, and checked the plugin code and is the one it does that SELECT * FROM wp_posts WHERE
    id = …
    how to solve?

    sorry, forgot to mention that i’m using the 3.3.0…will check the new version trying to understand the code…

    When I use the quick-edit with Auto-Post-Thumbnail version 3.3.2 installed, I get the same MySQL error.

    It looks like the reason is the usage of

    global $post_ID;

    which is empty when you save via ajax.

    To fix this, open the file auto-post-thumbnail.php and

    1) Replace:

    add_action('publish_post', 'apt_publish_post');


    add_action('publish_post', 'apt_publish_post', 10, 3 );

    2) Replace:

    function apt_check_required_transition($new_status='', $old_status='', $post='') {
        global $post_ID; // Using the post id from global reference since it is not available in $post object. Strange!
        if ('publish' == $new_status) {


    function apt_check_required_transition($new_status='', $old_status='', $post='') {
        if ('publish' == $new_status) {

    Hope this helps.

    ps: Here is the diff:

    < add_action('publish_post', 'apt_publish_post');
    > add_action('publish_post', 'apt_publish_post', 10, 3 );
    <     global $post_ID; // Using the post id from global reference since it is not available in $post object. Strange!
    <         apt_publish_post($post_ID);
    >         apt_publish_post($post->ID);


    in the above code (part 1) I meant:

    add_action('transition_post_status', 'apt_check_required_transition', 10, 3 );

    instead of

    add_action('publish_post', 'apt_publish_post', 10, 3 );

    just like I wrote earlier here:

    sorry about that 😉

    It seems like the author wants everyone to buy the pro version… Author; Are you supporting the free version?

    I hope the (free) plugin will be updated soon to fix these errors and the PHP notices.

    I’m just another user of the (free) plugin 😉

    Plugin Author tariquesani



    thanks for the diff will update next week. The free version will be supported but updates will be about once a month or so… The pro version will not empty your bank account either at just $7 🙂

    The money is not tha issue, but the policy is, does the trial not work or in any way interfear with the project instll itselfs, no go.

    Be smart ant always take care of your marketing showcases First, rather then improve/ expand a pro version – if you wanna have a spin on your 7 coins…

    We are gretaful to all contributors of code to this WP community, inlcuding “not working properly” applications and plugins. But using that as a method for selling or forcing donations, is not a good behaviour.

    I don telling this is the case with this plugin, but it is a warning flag for me anyway.

    It would be nice to see your work and if its working, we happlily donate/ “buy” the symbolic amount of cash…

    Plugin Author tariquesani


    Version 3.3.3 should have this fixed

    Thank you for the update. As it has been three months to resolve this issue, hope you are able to support the free version as well reasonably.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘You have an error in your SQL syntax’ is closed to new replies.