Ticket #4069 (closed defect (bug): fixed)

Opened 2 years ago

Last modified 2 years ago

query_posts('category_name=test') = database error

Reported by: devil1591 Assigned to: anonymous
Priority: high Milestone: 2.2
Component: General Version: 2.2
Severity: blocker Keywords:
Cc:

Description

If you make a

<?php query_posts('category_name=test'); ?>

before your loop, you will have this error

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND rel_type = 'category' AND (post_type = 'post' AND (post_st]
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_categories ON (wp_post2cat.category_id = wp_categories.cat_ID) WHERE 1=1 AND category_id IN () AND rel_type = 'category' AND (post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

Tested on a fresh trunk install

Change History

04/02/07 17:35:30 changed by devil1591

precision: the category name "test" doesn't exist here, but if you put an existing category name, it won't found it and will return the same error because of the empty IN ()

04/02/07 19:40:17 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

(In [5171]) Fix category_name=foo WP_Queries. fixes #4069