Support » Plugins and Hacks » Error with WP 3.5: wpdb::prepare()

Error with WP 3.5: wpdb::prepare()

  • Seems like this is a pretty common error with the new wp 3.5 release, but getting a “Missing argument 2 for wpdb::prepare() on line 75” error in the Posts page for the plugin after upgrade. It still seems to function ok for already selected posts on the front-end, but the error prevents selecting of any new posts.

    Assuming we wont be getting an upgrade since it hasn’t been updated in over 2 years but though someone here might have a fix?


Viewing 15 replies - 16 through 30 (of 60 total)
  • Hi Alex here’s the error i got at the footer of the site:
    Parse error: syntax error, unexpected ‘;’ in /home/bridgest/public_html/wp-content/themes/itworx_1.3/footer.php on line 35

    Hi Shadowspid,

    Sorry, I missed the error in the code when looking at it last time. It does have an unexpected “;” as the error states. Remove “;” from after

    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Footer Column 1')){

    It’s not needed there.


    many thanks alex.. i found out that the file was hacked.

    Hi there

    I’m experiencing a similar problem 🙁

    Stuck with an error(“Missing argument 2 for wpdb::prepare()…”) for the following code:

    function nws_get_theme_version() {
    global $wpdb;

    $th_vers = NULL;

    // the table
    $table = is_dbtable_there(‘status’);
    // the sql
    $th_vers = $wpdb->get_var( $wpdb->prepare( “SELECT th_vers FROM $table WHERE id = 1 LIMIT 0,1” ) );

    return $th_vers;

    Would appreciate it if anybody could help!

    Hello! Help me please! I’m experiencing a similar problem 🙁

    This lines with error (Warning: Missing argument 2 for wpdb::prepare() in /home/u119588452/public_html/wp-includes/wp-db.php on line 990):

    foreach ($files as $key=>$file) {
    $ar_file_id[] = $file->ID;
    $ar_link[$file->ID] = & $files[$key];


    usort ($files,’_sort_order’);
    foreach ($files as $ord=>$row) {
    if($row->menu_order == 0)
    $ar_link[$row->post_parent]->files[] = $row;
    $ar_link[$row->post_parent]->files[$row->menu_order] = $row;

    Plugin name – Ads_Wordpress.

    Help me? please!!!!:'(

    Hello vadim_k!

    Could you please post the line of code in question with prepare() function used? The lines of code that you posted don’t have that function. It’s hard to guess what errors they are outputting without errors specified.


    Alex, this?

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/u119588452/public_html/wp-content/plugins/ads-wordpress/ads_admin.php on line 23 and defined in /home/u119588452/public_html/wp-includes/wp-db.php on line 990

    Hi Vadim,

    I was trying to look for the plugin online to download it and see the code but I couldn’t find it.
    Please copy paste the code that is on line 23 in ads_admin.php in the plugin folder (ads-wordpress) and I’ll help you correct it. This is the line of code that needs to be changed since it’s using prepare() incorrectly (that’s what the error you posted tells us).

    Best regards,

    Hi, Alex!

    here the code that is on line 23:

    $ads_user_id = $wpdb->get_var( $wpdb->prepare( “SELECT ID FROM $wpdb->users WHERE user_login = ‘$ads_user_name'” ));

    But now is showing error with this text:
    Warning: Missing argument 2 for wpdb::prepare() in /home/u119588452/public_html/wp-includes/wp-db.php on line 990.

    p.s.: my English is bad, sorry, please…

    Alex, link for download this plugin

    Hi Vadim,

    Here’s what you have to change in ads_admin.php on line 23:

    $ads_user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_login = '$ads_user_name'" ));

    $ads_user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_login = '%s'", $ads_user_name ));

    Best regards,

    I am having the same error with the following lines:

    $where = $wpdb->prepare("WHERE p.post_date < '".$current_post_date."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' AND p.ID != '". $post->ID ."' $posts_in_ex_cats_sql");

    Is there anyone that could help me out? I am sorry, but I am not sure how to amend this myself 🙁

    Plugin Contributor Kapil Chugh


    Now you no longer need this plugin. You can simly use :


    Hello guys. I have the same problem with a file….

    The line is :
    $has_children = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(meta_id) FROM $wpdb->postmeta WHERE meta_key=’_menu_item_menu_item_parent’ AND meta_value='”.$item->ID.”‘”));

    Anyone ? A solution ?
    thanks a lot

    Anyone? Please . i want to go online with the site but i’m afraid of an SQL injection…

Viewing 15 replies - 16 through 30 (of 60 total)
  • The topic ‘Error with WP 3.5: wpdb::prepare()’ is closed to new replies.