WordPress.org

Forums

W4 Content tabset
Fix for PHP Warning: Missing argument 2 for wpdb::prepare() (3 posts)

  1. Mark Barnes
    Member
    Posted 1 year ago #

    To fix this warning (which occurs in WordPress 3.5+), just edit line 112 of functions.php. Change it from

    $query = $wpdb->prepare( "SELECT * FROM $wpdb->tabset ORDER BY tabset_id ASC", );
    to
    $query = $wpdb->prepare( "SELECT * FROM $wpdb->tabset ORDER BY tabset_id ASC", "" );

    http://wordpress.org/plugins/postpage-content-anchor-tabset/

  2. m6arate
    Member
    Posted 1 year ago #

    This suppresses the error, but is it a safe fix? If I understand the post linked below correctly, passing a variable in the prepare string exposes the site to a SQL injection attack.

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

    I'm not sure how to safely handle this situation.

  3. Mark Barnes
    Member
    Posted 1 year ago #

    If you look at the Codex, the examples given all place $wpdb inside the prepare string.

    If you don't do that, you would end up with quotes around the table name, which would break the MySQL, I think.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.