optimize all sql strings in posts.php