Had a cough for a few months and I just started coughing up blood. What is wrong with me?

See your doctor. Having recurring illness is troubling. In order to achieve a specific and correct doagnosis with symptoms like this, you'll need to visit your doctor. Only after a face-to-face evaluation will he/she be able to properly diagnose and treat you.