WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Missing Argument 2 for wpdb::prepare() (27 posts)

  1. sashamenis
    Member
    Posted 1 year ago #

    After updating wordpress to 3.5 I am getting this error.

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/cpanel/public_html/wp-content/themes/clipper/includes/admin/admin-options.php on line 291 and defined in /home/cpanel/public_html/wp-includes/wp-db.php on line 990

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/cpanel/public_html/wp-content/themes/clipper/includes/admin/admin-options.php on line 292 and defined in /home/cpanel/public_html/wp-includes/wp-db.php on line 990

    I am using, Akismet, Internal link builder, WP Security and WP Smush.it plugins. Is it related to any of these plugins?

  2. stephen.pfaff
    Member
    Posted 1 year ago #

    I am now having a similar error on one of my pages. I am not running any of the plugins you mentioned.

  3. stephen.pfaff
    Member
    Posted 1 year ago #

    My error was related to a 'nextgen-gallery' plugin.

    "Warning: Missing argument 2 for wpdb::prepare(), called in ../nextgen-gallery/lib/tags.php on line 315 and defined in ../wp-includes/wp-db.php on line 990"

    By the looks of it, wpdb::prepare() function, inside wp-db.php, now requires an array of arguments to be passed to it.
    example, $wpdb->prepare($query, $args)

    My gallery plugin used this function to submit a request query to the database but wasn't including any $args.

  4. betme88
    Member
    Posted 1 year ago #

    I have the same problem
    "Warning: Missing argument 2 for wpdb::prepare()" on my iphrom plugins

    this message come when i upgrade wordpress to 3.5 this morning

  5. stephen.pfaff
    Member
    Posted 1 year ago #

    Find the line in your error, add arguments parameter after query. This should fix it up on any script. Or you could always disable effected plugin until the author corrects.

  6. stephen.pfaff
    Member
    Posted 1 year ago #

    Check this, http://wordpress.org/support/topic/error-with-wp-35-wpdbprepare?replies=2

    The function now requires 2 parameters, as of WP 3.5

  7. Andrew Nacin
    Lead Developer
    Posted 1 year ago #

    If you're a user: Your site is fine. If you're a plugin/theme author, please read: http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/. If you're a user, please point your plugin/theme author to that post.

  8. sashamenis
    Member
    Posted 1 year ago #

    I have checked all the strings of all plugins.. but nothing there. The problem is showing in Admin files. admin-options.php and all.. what to do.?

  9. sashamenis
    Member
    Posted 1 year ago #

    Is there something in which anyone can help me? I got this code from admin-options.php

    <?php

    }

    do_action( 'appthemes_add_submenu_page_content' );

    function app_dashboard() {
    global $wpdb, $app_edition, $app_rss_feed;
    global $app_twitter_rss_feed, $app_forum_rss_feed, $options_dashboard;

    $count_live = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_status IN ('publish', 'unreliable') AND post_type = '".APP_POST_TYPE."'" ) );
    $count_pending = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '".APP_POST_TYPE."' AND post_status = 'pending'" ) );

    //$job_rev_total = $wpdb->get_var($wpdb->prepare("SELECT sum(mc_gross) FROM $wpdb->prefix" . 'clpr_order_info'));

    ?>

    What to change in this?

  10. keesiemeijer
    moderator
    Posted 1 year ago #

    First backup (download) the file by using FTP or whatever file management application your host provides.

    Try changing this:

    $count_live = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_status IN ('publish', 'unreliable') AND post_type = '".APP_POST_TYPE."'" ) );
    $count_pending = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '".APP_POST_TYPE."' AND post_status = 'pending'" ) );

    to this:

    $count_live = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_status IN ('publish', 'unreliable') AND post_type = '%s'",APP_POST_TYPE  ) );
    $count_pending = $wpdb->get_var( $wpdb->prepare( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '%s' AND post_status = 'pending'", APP_POST_TYPE ) );
  11. sashamenis
    Member
    Posted 1 year ago #

    Oh My God... Thank you Keesiemeijer... Thanks a lot.. You saved my BUTT :D

  12. keesiemeijer
    moderator
    Posted 1 year ago #

    You're welcome. I'm glad you got it resolved.

    Can you notify the theme author or vendor that their theme has some issues with WordPress 3.5.

  13. Roberto
    Member
    Posted 1 year ago #

    hi, i have the same error a little different but is here:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/xxxxxx/public_html/wp/wp-content/themes/xxxxxxxx/includes/admin/admin-options.php on line 843 and defined in /home/xxxxxxx/public_html/wp/wp-includes/wp-db.php on line 990

    -----------------

    $ad_rev_total = $wpdb->get_var( $wpdb->prepare( "SELECT sum(mc_gross) FROM $wpdb->cp_order_info" ) );
    		$customers_today = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = %s AND ($wpdb->usermeta.meta_value NOT LIKE %s) AND $wpdb->users.user_registered >= %s", $capabilities_meta, '%administrator%', $date_today ) );
    		$customers_yesterday = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = %s AND ($wpdb->usermeta.meta_value NOT LIKE %s) AND $wpdb->users.user_registered BETWEEN %s AND %s", $capabilities_meta, '%administrator%', $date_yesterday, $date_today ) );
    		$countusers = count_users();
    ?>

    anyone knows how to fix it ?

  14. keesiemeijer
    moderator
    Posted 1 year ago #

    As always back up the file the file by using FTP or whatever file management application your host provides.

    Try changing this:

    $ad_rev_total = $wpdb->get_var( $wpdb->prepare( "SELECT sum(mc_gross) FROM $wpdb->cp_order_info" ) );

    to this:

    $ad_rev_total = $wpdb->get_var( "SELECT sum(mc_gross) FROM $wpdb->cp_order_info"  );

    And please notify the theme author or vendor that their theme has an issues with WordPress 3.5.
    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/.

  15. Roberto
    Member
    Posted 1 year ago #

    Thank you so much keesiemeijer it solved !! No more appearing this error !
    I will definetely contact the vendor about it !

    have a nice day
    best regards,
    Snu

  16. keesiemeijer
    moderator
    Posted 1 year ago #

    @snurex
    I'm glad you got it resolved.

  17. 1echero
    Member
    Posted 1 year ago #

    dear keesiemeijer,

    I guess my problem is similar but concerns some other file. could you please help me? I have info:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/xxxxx/public_html/wp-content/themes/Nuance/functions/sidebars.php on line 83 and defined in /home/xxxxx/public_html/wp-includes/wp-db.php on line 990

    I will be grateful for your help because this problem concerns a lot of my websites. Of course I can send you more files to get to know the problem.

    Sidebars.php:

    /* User made sidebars */
    $w_count = 0;

    global $wpdb;

    $widgetized_pages = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'jw_sidebar'"));

    if($widgetized_pages){

    foreach($widgetized_pages as $w_page){

    $widget_id = strtolower(str_replace(' ', '_', $w_page));

    register_sidebar(array(
    'name' => $w_page,
    'id' => 'jw_widgetsection_'.$widget_id,
    'description' => '',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div><div class="separator"></div>',
    'before_title' => '<h5>',
    'after_title' => '</h5>'
    ));

  18. keesiemeijer
    moderator
    Posted 1 year ago #

    Another way of solving this issue is to not display any errors and contacting the the theme author or vendor that their theme has an issues with WordPress 3.5.

    Try it by opening your wp-config.php file and place these lines into it:

    ini_set( 'display_errors', false );
    error_reporting( 0 );

    @1echero
    If that doesn't work backup the file and try changing this:

    $widgetized_pages = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'jw_sidebar'"));

    to this:

    $widgetized_pages = $wpdb->get_col("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'jw_sidebar'");

    And please notify the theme author or vendor that their theme has an issues with WordPress 3.5.
    Show them this link: http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/.

  19. 1echero
    Member
    Posted 1 year ago #

    dear keesiemeijer, it works, thank you!

  20. keesiemeijer
    moderator
    Posted 1 year ago #

    You're welcome :-)
    Don't forget to contact the theme author or vendor that their theme has an issues with WordPress 3.5.

  21. ramizaher
    Member
    Posted 1 year ago #

    Hey

    I would appreciate it if anyone can help me fixing the issue here

    ERROR

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/!@#$%^/public_html/wp-content/plugins/no-future-posts/no-future-posts.php on line 74 and defined in /home/!@#$%^/public_html/wp-includes/wp-db.php on line 990
    
    Warning: Missing argument 2 for wpdb::prepare(), called in /home/!@#$%^/public_html/wp-content/plugins/no-future-posts/no-future-posts.php on line 81 and defined in /home/!@#$%^/public_html/wp-includes/wp-db.php on line 990

    lines between 74 and 81

    // set future posts
    	$sql = "UPDATE	$tposts
    			SET		post_status = 'publish'
    			WHERE	post_status = 'future'
    			AND		id NOT IN ($e_posts)";
    	$wpdb->query($wpdb->prepare($sql));
    
    	// reset excluded posts
    	$sql = "UPDATE	$tposts
    			SET		post_status = 'future'
    			WHERE	id IN ($e_posts)
    			AND		post_date > now()";
    	$wpdb->query($wpdb->prepare($sql));
    
    	NoFuturePosts::update_count();
    }

    please let me know how to fix it, Thanks

  22. keesiemeijer
    moderator
    Posted 1 year ago #

    Have you tried the not showing errors method above?

    Is the $e_posts varable a number or a string?

  23. ramizaher
    Member
    Posted 1 year ago #

    Nope didnt try the not showing error

    Here is the e_posts

    // get excluded post IDs...
    	$e_posts = get_option('nofutureposts_posts');
    	if ( empty($e_posts) )
    		$e_posts = 0;
    $res = $wpdb->get_results($wpdb->prepare($sql));
    		foreach ( $res as $r )
    			$e_posts .= ','.$r->ID;
  24. javiroces
    Member
    Posted 1 year ago #

    Hello there! As stephen.pfaff said: i have the same error:

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/jobqibhp/public_html/wp-content/plugins/nextgen-gallery/lib/tags.php on line 318 and defined in /home/jobqibhp/public_html/wp-includes/wp-db.php on line 990

    Any suggestion? Thank you so much!

  25. esmi
    Forum Moderator
    Posted 1 year ago #

  26. tahir1977
    Member
    Posted 1 year ago #

    After updating wordpress 3.5 i look this any body can help me Warning: Missing argument 2 for wpdb::prepare(), called in /home/redinfot/public_html/wp-content/themes/classipress/includes/admin/write-panel.php on line 42 and defined in /home/redinfot/public_html/wp-includes/wp-db.php on line 990
    Ad Info:

  27. esmi
    Forum Moderator
    Posted 1 year ago #

    See the link I posted above.

Topic Closed

This topic has been closed to new replies.

About this Topic