WordPress.org

Forums

WordPress Wiki
Missing argument 2 for wpdb::prepare() (3 posts)

  1. Ron Fredericks
    Member
    Posted 2 years ago #

    Hi Folks.

    I have a few clients using this wiki and found on upgrading to wordpress 3.6, the rss feed for wordpress wiki 1.0.2 has the following error message:

    Missing argument 2 for wpdb::prepare() on line 42 in wordpress-wiki/controllers/wiki_feed.php

    After reading this link:
    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    I made the following change to line 42 in wiki_feed.php


    // $posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where $where
    // order by post_modified desc")); // original
    $posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where $where
    order by post_modified desc",0)); // updated hack to fix the error message (still not safe from SQL injection however, Ron Fredericks 8/29/2013

    http://wordpress.org/plugins/wordpress-wiki/

  2. Ron Fredericks
    Member
    Posted 1 year ago #

    same problem in one more file: wiki_dashboard_widget.php

    on line 12, add dummy 0 , as 2nd argument to $wpdb->prepare() like this:


    $posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where ID in (
    select post_id from $wpdb->postmeta where
    meta_key = 'wiki_page' and meta_value = 1)
    or post_type in ('wiki') order by post_modified desc limit 5", 0)); // add dummy variable to satisfy argument 2 warning, RDF

  3. Tradock
    Member
    Posted 1 year ago #

    Hi,
    I have the same problem but in the Ads section: Warning: Missing argument 2 for wpdb::prepare(), called in /home/qantroco/public_html/clisko.com/wp-content/themes/classipress/includes/admin/admin-options.php on line 870 and defined in /home/qantroco/public_html/clisko.com/wp-includes/wp-db.php on line 992. I found the stream but don't know how to modify it.

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

    line 992: function prepare( $query, $args ) {

    Any help would be appreciated.
    Regards,
    Tradock

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Wiki
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic