WordPress.org

Ready to get started?Download WordPress

Forums

Peter's Post Notes
[resolved] Error when attaching note to post with Peters' Post Notes (6 posts)

  1. wpmhweb
    Member
    Posted 1 year ago #

    After updating to WP 3.5 and I try to publish a post with a note I get this error:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/html/wp-content/plugins/peters-post-notes/peters_post_notes.php on line 317 and defined in /home/content/html/wp-includes/wp-db.php on line 990

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/html/wp-includes/wp-db.php:990) in /home/content/html/wp-includes/pluggable.php on line 876

    http://wordpress.org/extend/plugins/peters-post-notes/

  2. jharker
    Member
    Posted 1 year ago #

    I had the same problem and found the following solution. In wp-content/plugins/peters-post-notes/peters-post-notes.php, around line 314, the original (buggy) code is this:

    $latest_note = $wpdb->get_var( $wpdb->prepare( "SELECT notecontent FROM " . $ppn_db_notes .
    "WHERE postid = " . $post_id .
    "ORDER BY notetime DESC
    LIMIT 1;" ) );

    To fix it, remove the above and replace it with:


    $latest_note = $wpdb->get_var( $wpdb->prepare( "SELECT
    notecontent FROM %s WHERE postid = %d ORDER BY notetime DESC LIMIT 1;", $ppn_db_notes, $post_id ) );

  3. wpmhweb
    Member
    Posted 1 year ago #

    Hey! Thank You. Worked like a charm!

  4. jharker
    Member
    Posted 1 year ago #

    Hmph. This doesn't really show up properly here, since the original and fixed code all contain backticks. I wish there was a preview option.

    Anyway, here's the same thing using quotes. The original code was:

    $latest_note = $wpdb->get_var( $wpdb->prepare( 'SELECT "notecontent" FROM $ppn_db_notes
                                                            WHERE "postid" = $post_id
                                                            ORDER BY "notetime" DESC
                                                            LIMIT 1;' ) );

    And the fixed version, which works for me, is:

    $latest_note = $wpdb->get_var( $wpdb->prepare( 'SELECT "notecontent" FROM %s WHERE "postid" = %d ORDER BY "notetime" DESC LIMIT 1;', $ppn_db_notes, $post_id ) );

    The "fixed" code can be copied and pasted as-is, no need to change the quotes or anything.

    Hope this helps!

  5. asafche
    Member
    Posted 1 year ago #

    i hope that peter will add this to the next update

  6. Peter
    Member
    Plugin Author

    Posted 1 year ago #

    Hi all, thanks for reporting this. I've fixed it in version 1.4.0 of the plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic