Hello webmasters..
I updated the wp 3.5 version of my site..
Due to which there a warning message-
(Warning: Missing argument 2 for wpdb::prepare(), called in /home/theultim/public_html/wp-content/plugins/sharebar/sharebar.php on line 112 and defined in /home/theultim/public_html/wp-includes/wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in /home/theultim/public_html/wp-content/plugins/sharebar/sharebar.php on line 124 and defined in /home/theultim/public_html/wp-includes/wp-db.php on line 990) coming on the start of each post of my site..
Please tell me how can i resolve it..??
thanks..!!

Dani AI

Generated

— that warning comes from the Sharebar plugin calling $wpdb->prepare() without supplying the replacement values. WordPress core started flagging calls to prepare() that lack a second argument (so plugins that used prepare() with only the SQL string now trigger a PHP warning). @LastMitch and pointed toward that core change.

Quick fixes (in order of safety):

  1. Update or remove the Sharebar plugin. If an updated release is available it will fix the calls without manual edits.

  2. If no update is available, edit wp-content/plugins/sharebar/sharebar.php (backup first). If a prepare() call has no placeholders, remove prepare() and run the query directly. If placeholders are intended, pass the replacement variables.

Example: use a plain query when there are no %d/%s placeholders:

$sql = "SELECT * FROM $wpdb->posts WHERE post_status = 'publish'";
$rows = $wpdb->get_results( $sql );

Example: use prepare() correctly with placeholders:

$sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id );
$rows = $wpdb->get_results( $sql );
  1. Temporary silence (only while you fix the plugin): disable display of PHP warnings rather than editing plugins on a production site. Set this in wp-config.php:
    define( 'WP_DEBUG', false );
    define( 'WP_DEBUG_DISPLAY', false );

Notes and cautions: always backup before editing plugin files. Edits will be overwritten by plugin updates — consider forking the plugin or asking the plugin author to push a fix. For details on the correct API and debugging, see the wpdb::prepare reference and WordPress debugging notes: wpdb::prepare and Debugging in WordPress.

Recommended Answers

All 2 Replies

@LastMitch thanks for sharing so informative post, many question solve after reading this post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.