WordPress.org

Support

Support » Plugins and Hacks » Disqus Comment System » PHP Warning: Missing argument 2 for wpdb::prepare()

PHP Warning: Missing argument 2 for wpdb::prepare()

Viewing 8 replies - 1 through 8 (of 8 total)
  • yes i’ve got the same error

    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

    Nice job! Thanks!

    How is it working for you so far?

    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.

    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.

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

    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");
    
            }
    esmi

    @esmi

    Forum Moderator

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘PHP Warning: Missing argument 2 for wpdb::prepare()’ is closed to new replies.
Skip to toolbar