Welcome to HealthcareMagic.
There are possibilities that you have a liver
disease which is causing your pain and brown mucus.There are also chances that you could be having an ulcer in your stomach along with impaired liver function , which causes your symptoms.
i advise you to visit your Doctor and get an Upper GI endoscopy
.This helps in seeing if there is any ulcer of bleeding source like varices
.Since these can happen in liver disease , it is needed that you should get liver function test done.