SELECT loc_id, pr_id, f_name, name, beds, swap_friends.user_id_friend as id FROM swap_property, swap_friends, swap_location, swap_user WHERE swap_friends.user_id= AND accepted=1 AND (swap_property.user_id=swap_friends.user_id_friend) AND (swap_user.user_id=swap_friends.user_id_friend) AND (swap_location.id=swap_property.loc_id) - 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 accepted=1 AND (swap_property.user_id=swap_friends.user_id_friend) AND (swap' at line 1