I had a brief bout with them, but thankfully the two I had went away after about a week. Unfortunately, I have a chronic fissure, which is a whole other little hell but prevention is similar for both plagues.
Here's what works for me:
Go buy some Miralax or a generic. Start with half a cap a day instead of the full dose; if you find you need softer stool afterward, up the dosage a little but I wouldn't recommend exceeding the full dosage unless you want diarrhea. From my understanding, unlike other laxatives, Miralax isn't habit forming due to the way it works (don't hold me to this though). I've been using it for a few months now after having no success with regular stool softeners like dulcolax.
Avoid dairy, white bread, white rice, large amounts of pasta, large amounts of meat.
Eat more whole wheat, oats, brown rice, beans, veggies, fruits (any fruit that start with a "P" will soften stool -- pears & peaches are especially good. Apples and bananas may bind you up actually, depends on ripeness and the individual), try switching to olive oil, lastly drink lots of water and never allow yourself to get dehydrated.
Make sure every time you eat, you are getting some sort of fiber. If you don't currently get much fiber, probably not a good idea to go whole hog right away, slowly increase it and see how you do.
Also, go see a doctor!