There are a lot of things that could account for a bad taste in your mouth. If the greenish colored phlegm you are referring to is in the shape of tiny balls or rocks, these are actually called tonsiloliths and are quite revolting. They're food, bacteria and white blood cells that accumulate in the crevices of your tonsils and then you spit them up now and again and taste like (*&^%$##..... Try an antibacterial mouthwash and an oxygenating toothpaste.