A Database Error Occurred

Error Number: 1064

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 madacms_posts.status = '1' ORDER BY `post_id` desc LIMIT 1' at line 37

SELECT madacms_posts.post_id AS test_post_id, madacms_posts.post_id AS post_id, madacms_posts.priority AS priority, FROM_UNIXTIME(madacms_posts.date, '%Y/%m/%d') AS date, madacms_posts.date AS unix_date, madacms_posts.title AS title, madacms_posts.subtitle AS subtitle, madacms_posts.excerpt AS excerpt, madacms_posts.content AS content, madacms_posts.status AS status, madacms_posts.tags AS tags, madacms_posts.category AS category, madacms_posts.url_title AS url_title, madacms_posts.front_image AS front_image, madacms_posts.post_image AS post_image, madacms_posts.template AS template, madacms_posts.allow_comments AS allow_comments, madacms_posts.attachments AS attachments, madacms_posts.images AS images, madacms_posts.pub_user_id AS pub_user_id, madacms_posts.pub_year AS pub_year, madacms_posts.pub_edition AS pub_edition, madacms_posts.pub_pages AS pub_pages, madacms_posts.pub_size AS pub_size, madacms_posts.post_type AS post_type, madacms_posts.about_book AS about_book, madacms_post_stats.post_visits AS post_visits, madacms_writers.user_id AS user_id, madacms_writers.display_name AS author, madacms_writers.writer_image AS writer_image, madacms_writers.country_id AS country_id, madacms_writers.writer_desc AS writer_desc, (SELECT COUNT(madacms_comments.comment_id) FROM madacms_comments WHERE madacms_comments.post_id = madacms_posts.post_id) AS comment_count FROM (`madacms_posts`) JOIN `madacms_writers` ON madacms_writers.user_id = madacms_posts.user_id LEFT JOIN `madacms_post_stats` ON madacms_post_stats.post_id = madacms_posts.post_id WHERE madacms_posts.post_id = " AND madacms_posts.status = '1' ORDER BY `post_id` desc LIMIT 1