Water, raisins, prunes, dried fruit, dried cranberries, prune juice, all that good stuff, if that doesn't help, talk to your doctor and she/he should be able to prescribe the appropriate medication for you.
Best long-term solution is Fiber. Easy way to ensure you get it every day drink some Psyllium Fiber(chk Wikipedia for good background on it's many benefits) sold under brand names such as Metamucil but "no-name" versions for most part equal; just chk actual% of Psyllium per ounce. Saved my Grandma's from loosing lg part stomach, my husband no more prob's from Diriticulitis and me from "Travelers Constipation" AND OPPOSITE. Yep works for both! Well worth it. Also you mention that it hurts? Have you checked wether you may have Hemmorhoids?