Hey folks,
[EDIT to correct 2.5.1 to 2.6]
Upgrade from 1.5.1 to 2.6 PHP5.
Post images are not displayed for some posts.
The db err log shows the following error for each affected post.
[28-Jul-2008 18:50:23] 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 'wp_1_posts.ID DESC LIMIT 0, 1' at line 1 for query SELECT SQL_CALC_FOUND_ROWS wp_1_posts.* FROM wp_1_posts WHERE 1=1 AND wp_1_posts.post_parent = 4 AND (post_mime_type LIKE 'image/%') AND wp_1_posts.post_type = 'attachment' AND (wp_1_posts.post_status = 'inherit') ORDER BY ,wp_1_posts.ID DESC LIMIT 0, 1 made by get_posts
Let me try some spacing for my tired eyes...
Drama occurs here: 'wp_1_posts.ID DESC LIMIT 0, 1'
SELECT SQL_CALC_FOUND_ROWS wp_1_posts.*
FROM wp_1_posts
WHERE 1=1
AND wp_1_posts.post_parent = 7
AND (post_mime_type LIKE 'image/%')
AND wp_1_posts.post_type = 'attachment'
AND (wp_1_posts.post_status = 'inherit')
ORDER BY ,wp_1_posts.ID DESC LIMIT 0, 1
made by get_posts
Ah, made by get_posts, hmm, ok. Possibly that leading comma after ORDER BY?
Help me out here folks, wp-includes/query.php starting @ line 1249 is the section of code that deals with the order by statement where I see $orderby = "$wpdb->posts.ID";
That jives with wp_1_posts.ID
. Ok, so before that point in the code then... line 1443
$orderby = 'ORDER BY ' . $orderby;
Doh! No comma insertion.
Anyone else with image errors?
Thanks.