WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5729 closed defect (bug) (duplicate)

SQL error regarding incorrect syntax-comment.php

Reported by: KirkM Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3.2
Component: General Keywords: SQL
Focuses: Cc:

Description

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.

Change History (2)

comment:1 ryan6 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

See #5185 and #5471

comment:2 Nazgul6 years ago

  • Milestone 2.5 deleted
Note: See TracTickets for help on using tickets.