Aneed Hamas
Aneed Hamas

Reputation: 43

Warning: Missing argument 2 for wpdb::prepare() plugin issue

I updated WordPress to the latest version 3.6 and i got this warning in regards to the wpdb::prepare().

It is an issue with the theme's plugin for sliders. I don't know how to edit $wpdb->prepare on this file to make it work with the new WP version.

   <?php            $item_count = 0;                        foreach ($sliders as $key => $slider){                                  $cur_slider_id = $key+1;                $item_count = $wpdb->get_var($wpdb->prepare("SELECT count(c_id) FROM ". $item_table ." WHERE s_id = '". $cur_slider_id ."'"));              ?>


$count_filter = $wpdb->get_var($wpdb->prepare("SELECT count(id) FROM ". $item_table ." WHERE c_id REGEXP '(^".$d.",)|(,".$d."$)|(,".$d.",)|^".$d."$'")); 


$item_count = $wpdb->get_var($wpdb->prepare("SELECT count(c_id) FROM ". $item_table ." WHERE c_id RLIKE '^".$h."$' OR c_id RLIKE ',".$h."$' OR c_id RLIKE '^".$h.",' OR c_id RLIKE ',".$h.",' " ));

I have these 3 lines that contain the $wpdb->prepare(), please help on how to change this to the way that WP 3.6 accept it?

Thank you,

Upvotes: 0

Views: 2526

Answers (4)

BigTech
BigTech

Reputation: 460

I was very happy when I past this code in my wp-config.php file. Warning message was not display again.

@ini_set('display_errors', 0);

Upvotes: 1

Sudar
Sudar

Reputation: 19992

You are using wpdb->prepare() function in a wrong way. Read http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/ to find out how to fix it properly.

Upvotes: 0

Aneed Hamas
Aneed Hamas

Reputation: 43

Adding "null" as a second argument to the function fixes the problem completely.

Upvotes: 0

Ben Racicot
Ben Racicot

Reputation: 5903

Where is $item_table defined? Maybe print it to make sure it's got what you want.

Upvotes: 0

Related Questions