jharker
Forum Replies Created
-
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 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 .
“WHEREpostid
= ” . $post_id .
“ORDER BYnotetime
DESC
LIMIT 1;” ) );To fix it, remove the above and replace it with:
$latest_note = $wpdb->get_var( $wpdb->prepare( "SELECTnotecontent
FROM %s WHEREpostid
= %d ORDER BYnotetime
DESC LIMIT 1;”, $ppn_db_notes, $post_id ) );