Title: wpdb::prepare bug
Last modified: January 4, 2024

---

# wpdb::prepare bug

 *  Resolved [nexbridge](https://wordpress.org/support/users/nexbridge/)
 * (@nexbridge)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wpdpprepare-bug/)
 * After the last update (4.1.16) we’ve started seeing the following PHP errors:
 * > Function wpdb::prepare was called incorrectly. The query does not contain the
   > correct number of placeholders (1) for the number of arguments passed (3).
 * Digging further, the issue seems to be on line 173 in class-googlesitemapgeneratorstandardbuilder.
   php:
 *     ```wp-block-code
       $q = $wpdb->prepare( $qs, $post_type, $year, $month ); 
       ```
   
 * Where $qs is given by:
 *     ```wp-block-code
       $qs = "
       	SELECT
       		p.ID,
       		p.post_author,
       		p.post_status,
       		p.post_name,
       		p.post_parent,
       		p.post_type,
       		p.post_date,
       		p.post_date_gmt,
       		p.post_modified,
       		p.post_modified_gmt,
       		p.comment_count
       	FROM
       		{$wpdb->posts} p
       	WHERE
       		p.post_password = ''
       		AND p.post_type = '%s'
       		AND p.post_status = 'publish'
       		{$ex_post_s_q_l}
       		{$ex_cat_s_q_l}
       	ORDER BY
       		p.post_date_gmt DESC
       	LIMIT
       		{$limit}
       ";
       ```
   
 * So presumably line 173 just needs changing to this?
 *     ```wp-block-code
       $q = $wpdb->prepare( $qs, $post_type );
       ```
   
    -  This topic was modified 2 years, 4 months ago by [nexbridge](https://wordpress.org/support/users/nexbridge/).
      Reason: Fixed typo

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [nexbridge](https://wordpress.org/support/users/nexbridge/)
 * (@nexbridge)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wpdpprepare-bug/#post-17322712)
 * Just to add that another update has now come out (4.1.17) and the line in question
   is now 177.
 *  Plugin Author [Auctollo](https://wordpress.org/support/users/auctollo/)
 * (@auctollo)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wpdpprepare-bug/#post-17345514)
 * [@nexbridge](https://wordpress.org/support/users/nexbridge/), we believe this
   is fixed in the next version (v4.1.18). Please confirm.
 *  Thread Starter [nexbridge](https://wordpress.org/support/users/nexbridge/)
 * (@nexbridge)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/wpdpprepare-bug/#post-17345645)
 * Yes this is now fixed – thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wpdb::prepare bug’ is closed to new replies.

 * ![](https://ps.w.org/google-sitemap-generator/assets/icon-256x256.png?rev=2713572)
 * [XML Sitemap Generator for Google](https://wordpress.org/plugins/google-sitemap-generator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-sitemap-generator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-sitemap-generator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-sitemap-generator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-sitemap-generator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-sitemap-generator/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [nexbridge](https://wordpress.org/support/users/nexbridge/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/wpdpprepare-bug/#post-17345645)
 * Status: resolved