Bad SQL Query: SELECT i.image_id, IF(i.year1 > 0, CONCAT(i.year, '-', i.year1), i.year) year, i.source, i.numaddimg, i.cat_id, i.user_id, i.image_name image_name, simpleproc(i.image_description,150) image_description,
i.image_keywords image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file,
i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating,
i.image_hits, c.cat_name cat_name, u.user_name,
il.latitude, il.longitude, il.direction, il.set_by_user_id, il.image_id AS marked_on_map, ,
IF(um.type = "vip" OR u.user_level = 9, 1, 0) AS user_vip, IF(c.auth_viewimage = 7, 1, 0) AS cat_vip_only
FROM (4im_images i, 4im_categories c)
LEFT JOIN 4im_users u ON (u.user_id = i.user_id)
LEFT JOIN 4im_images_location AS il ON il.image_id = i.image_id
LEFT JOIN 4im_user_membership AS um ON um.user_id = u.user_id AND (um.is_unlimited = 1 OR um.end_date >= "2018-04-24")
WHERE i.image_active = 1 AND c.cat_id = i.cat_id
AND i.cat_id NOT IN (0) AND i.image_name <> '' AND c.cat_name <> ''
ORDER BY i.image_date DESC
LIMIT 6
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 '
IF(um.type = "vip" OR u.user_level = 9, 1, 0) AS user_vip, IF(c.auth_viewimage ' at line 5