WordPress.org

Forums

Disqus Comment System
PHP Warning: Missing argument 2 for wpdb::prepare() (5 posts)

  1. theweedblog
    Member
    Posted 6 months ago #

    I'm getting this error in my php error log. It has to do with the wordpress 3.5 upgrade.

    Here's the error:

    PHP Warning: Missing argument 2 for wpdb::prepare(), called in \mysite.com\wp-content\plugins\disqus-comment-system\disqus.php on line 285 and defined in mysite.com\wp-includes\wp-db.php on line 990

    Here's some stuff I was reading that clued me into the problem:

    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    I tried to fix it myself, but I'm having trouble. Here's the line of code:

    $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:{$comment->id}' LIMIT 1"), ARRAY_A);

    Anyone now how to fix this besides turning off my error log?

    Thanks!

    http://wordpress.org/extend/plugins/disqus-comment-system/

  2. woppywush
    Member
    Posted 5 months ago #

    yes i've got the same error

  3. Speeddymon
    Member
    Posted 5 months ago #

    I think you need to change

    $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:{$comment->id}' LIMIT 1"), ARRAY_A);

    to like this

    $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:{%d}' LIMIT 1"), $comment->id, ARRAY_A);

    So change the bottom line only -- Disqua/1.0:{CHANGETHISHEREASDASHAHASDHA} and move $comment->id to just before ARRAY_A

    I am testing it now on my site

  4. theweedblog
    Member
    Posted 5 months ago #

    Nice job! Thanks!

    How is it working for you so far?

  5. Speeddymon
    Member
    Posted 5 months ago #

    I placed the variable incorrectly in my previous post.

    You can copy and paste this -- replace line 285 as follows:

    $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:{%d}' LIMIT 1", $comment->id), ARRAY_A);

    I just changed this on my own site, so we will see how it works.

Reply

You must log in to post.

About this Plugin

About this Topic