Support » Plugin: Peter's Post Notes » Error when attaching note to post with Peters' Post Notes

  • Resolved wpmhweb

    (@wppit)


    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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • jharker

    (@jharker)

    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 ) );

    wpmhweb

    (@wppit)

    Hey! Thank You. Worked like a charm!

    jharker

    (@jharker)

    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!

    i hope that peter will add this to the next update

    Plugin Author Peter

    (@pkthree)

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error when attaching note to post with Peters' Post Notes’ is closed to new replies.