[wp-trac] [WordPress Trac] #5729: SQL error regarding incorrect syntax-comment.php

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 29 16:33:28 GMT 2008


#5729: SQL error regarding incorrect syntax-comment.php
---------------------+------------------------------------------------------
 Reporter:  KirkM    |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.5      
Component:  General  |     Version:  2.3.2    
 Severity:  normal   |    Keywords:  SQL      
---------------------+------------------------------------------------------
 I have this error showing up in my error.log (root) since my host upgraded
 to PHP 5.2.5 and MySQL 5.0.45:

 "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 comment_approved = '1' ORDER BY comment_date_gmt DESC
 LIMIT 5' at line 1 for query SELECT wp_comments.* FROM wp_comments WHERE
 comment_post_ID = AND comment_approved = '1' ORDER BY comment_date_gmt
 DESC LIMIT 5"

 This error does not seem to affect site functions at all.

 This seems to revolve around lines 141 to 148 of 2.3.2's "comment.php"
 (wp-includes):

 {{{
 $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM
 $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved =
 '1' ORDER BY comment_date_gmt DESC LIMIT 1");
                                 break;
                         case 'blog':
                                 $lastcommentmodified =
 $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE
 comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY
 comment_date_gmt DESC LIMIT 1");
                                 break;
                         case 'server':
                                 $lastcommentmodified =
 $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL
 '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt
 <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT
 1");
                                 break;
 }}}

 Unfortunately I can't take this any farther since I'm not up to speed yet
 on code and syntax. I'm also a first timer posting here but I figured this
 is the best place to post this kind of problem. Please correct me if I'm
 wrong.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5729>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list