WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. theweedblog
    Member
    Posted 1 year 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 1 year ago #

    yes i've got the same error

  3. Speeddymon
    Member
    Posted 1 year 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 1 year ago #

    Nice job! Thanks!

    How is it working for you so far?

  5. Speeddymon
    Member
    Posted 1 year 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.

  6. JorritSchippers
    Member
    Posted 11 months ago #

    Shouldn't it be:

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

    The { and } character were there to get the right PHP variable.

  7. Speeddymon
    Member
    Posted 11 months ago #

    You're probably right, but I haven't seen any issues with it the way I put it though.

  8. dsignbywp
    Member
    Posted 10 months ago #

    Can you help me? Please

    if (!function_exists('cp_get_ad_details')) {
        function cp_get_ad_details($postid, $catid, $locationOption = 'list') {
            global $wpdb;
            //$all_custom_fields = get_post_custom($post->ID);
            // see if there's a custom form first based on catid.
            $fid = cp_get_form_id($catid);
    
            // if there's no form id it must mean the default form is being used
            if(!($fid)) {
    
    			// get all the custom field labels so we can match the field_name up against the post_meta keys
    			$sql = $wpdb->prepare("SELECT field_label, field_name, field_type FROM ". $wpdb->prefix . "cp_ad_fields");
    
            } else {
    
                // now we should have the formid so show the form layout based on the category selected
                $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, m.field_pos "
                         . "FROM ". $wpdb->prefix . "cp_ad_fields f "
                         . "INNER JOIN ". $wpdb->prefix . "cp_ad_meta m "
                         . "ON f.field_id = m.field_id "
                         . "WHERE m.form_id = '$fid' "
                         . "ORDER BY m.field_pos asc");
    
            }
  9. esmi
    Forum Moderator
    Posted 10 months ago #

    As per the Forum Welcome, please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic