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 '1509508900'%' OR phpfox_m2bmusic_album_song.title LIKE '% AND m2bmusic_album.ti' at line 1 SQL was: SELECT COUNT(song_id) AS album_song_total FROM phpfox_m2bmusic_album_song LEFT JOIN phpfox_m2bmusic_album ON phpfox_m2bmusic_album_song.album_id = phpfox_m2bmusic_album.album_id LEFT JOIN phpfox_m2bmusic_singer ON phpfox_m2bmusic_singer.singer_id = phpfox_m2bmusic_album_song.singer_id LEFT JOIN phpfox_user ON phpfox_m2bmusic_album.user_id = phpfox_user.user_id LEFT JOIN phpfox_m2bmusic_category on phpfox_m2bmusic_album_song.cat_id = phpfox_m2bmusic_category.cat_id WHERE 1 = 1 AND phpfox_m2bmusic_album_song.singer_id = 14 AND month(phpfox_m2bmusic_album.creation_date)=month(CURRENT_DATE()) and year(phpfox_m2bmusic_album.creation_date)=year(CURRENT_DATE()) AND (phpfox_user.full_name LIKE '% AND m2bmusic_album.time_stamp >= '1509508900'%' OR phpfox_m2bmusic_album_song.title LIKE '% AND m2bmusic_album.time_stamp >= '1509508900'%') AND search = 1 AND ( phpfox_m2bmusic_album.module_id IS NULL OR phpfox_m2bmusic_album.module_id = "") AND (phpfox_m2bmusic_album.user_id = 0 OR phpfox_m2bmusic_album.privacy IN (0) OR (phpfox_m2bmusic_album.privacy = 4 AND 0 IN (SELECT phpfox_friend_list_data.friend_user_id FROM phpfox_friend_list INNER JOIN phpfox_privacy ON phpfox_privacy.friend_list_id = phpfox_friend_list.list_id INNER JOIN phpfox_user ON phpfox_user.user_id = phpfox_privacy.user_id INNER JOIN phpfox_friend_list_data ON phpfox_friend_list.list_id = phpfox_friend_list_data.list_id WHERE phpfox_privacy.module_id = "musicsharing_album" AND phpfox_privacy.item_id = phpfox_m2bmusic_album.album_id)) OR (phpfox_m2bmusic_album.privacy = 3 AND phpfox_m2bmusic_album.user_id = 0) OR (phpfox_m2bmusic_album.privacy IN (1) AND phpfox_m2bmusic_album.user_id IN (SELECT fr.user_id FROM phpfox_friend as fr WHERE fr.friend_user_id = 0)) OR (phpfox_m2bmusic_album.privacy IN (2) AND (phpfox_m2bmusic_album.user_id IN (select f.user_id from phpfox_friend as f inner Join (select ffxf.friend_user_id from phpfox_friend as ffxf where ffxf.is_page=0 and ffxf.user_id = 0) as sf ON sf.friend_user_id = f.friend_user_id join phpfox_user as u ON u.user_id = f.friend_user_id) OR phpfox_m2bmusic_album.user_id IN (SELECT fr.user_id FROM phpfox_friend as fr WHERE fr.friend_user_id = 0)))) AND phpfox_m2bmusic_album_song.is_locked = 0 ORDER BY phpfox_m2bmusic_album_song.song_id DESC