SQL Query Syntax Error
-
I’m seeing an error in my debug.log that looks like this:
[26-Aug-2016 11:08:19 UTC] 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… for query SELECT ID FROM wp_tablename WHERE post_status=’draft’ AND post_type=’attachment’ AND post_author = 13 AND post_parent = ORDER BY ID DESC LIMIT 1…
In the get_attachment_from_draft_submission function there is this on line 1781:
$query = “SELECT ID FROM “.$table.” WHERE post_status=’draft’ AND post_type=’attachment’ AND post_author = $user_ID AND post_parent = “.$post_id.” ORDER BY ID DESC LIMIT 1″;
Unfortunately there is no check to see if the $post_id variable is valid, so the query is being created with an empty value for post_parent, resulting in an invalid query.
- The topic ‘SQL Query Syntax Error’ is closed to new replies.