My point is, no matter how tough and experienced you think you are, you've got to watch what you eat. This little episode aside, I think I can safely say I get sick way less often than your average traveler. This is because I tend to follow a few rules about food.
These are probably not the rules you think they are.
The Center for Disease Control has a saying about food while traveling: "if you can't peel it or cook it, forget it." This is a great guideline if you feel like living in a giant hamster ball. I can almost guarantee you that you will not get sick from food if you don't break this rule. I can also almost guarantee you that at some point, you will break it. If and when you do, you want to do it in an intelligent manner. That's where me and this entry come in.
Lesson number one: In the developing world, street food is often safer than restaurant food. Yes, you read that correctly. Street food. The food that has made me the most sick while traveling has almost all come from restaurants. The reason why, is that with street food, you see it get cooked right in front of you, and you see who is cooking it. In restaurants, you see neither. The methods the respective cooks use isn't much different. But with street food, if the cook is coughing up black goo into the same hands (s)he's smushing your falafel with, you know to go elsewhere. In a restaurant, you don't know whether that's happening or not. If the food is cooked right in front of you, fresh, by a healthy, clean-looking chef, you're in better shape than if it's sitting behind a glass case with insects buzzing around inside. And if it's in a restaurant, you just won't know-- many of these places aren't subjected to the same food code they are in the developed world, and even in the developed world, if you've ever worked in the food service industry, you know some of these rules can be... well, I think you get my point.
Lesson number two: usually, if the tap water isn't safe, neither is the ice. This is seems obvious when written, but it's one a lot of of people forget in practice. There are a few countries, mostly in Asia, where ice is actually factory made from safe water. But please take the extra step and check that that's the kind of ice floating in your drink. Ask.
Lesson number three: what's safe for the locals isn't necessarily safe for you, yet. Legend has it that when Japanese baseball superstar Ichiro Suzuki first came to the United States and ate a hamburger, he was violently ill. We all have little local beneficial bacteria running around our digestive tracts that helps us handle the local food. This differs from place to place. So take it easy for the first few days in a new place to develop your own. Supposedly local yogurt helps with this (though beware, eating yogurt that hasn't been refrigerated properly or that has expired is a fast way to making you sick). After you've been eating tame food (like vegetarian dishes) in a place for a bit, then try moving on to the more interesting stuff.
Lesson number four (this one is important): if the place is crowded, the food is probably good, and it's almost definitely being cooked fresh. This is an excellent way to pick street food vendors and restaurants. We'll call it the sheep method. The reason is that deserted restaurants and vendors are much more likely to leave things like meat lying around in temperatures that let nasty things start growing in it. Then when you order it, it'll get quickly reheated and served. Popular vendors, on the other hand, are having to constantly cook fresh batches to meet demand. And if it's in that much demand from the locals, it's probably because the food is especially good.
That should be enough to get you started. Everyone's body is slightly different, and soon you will develop your own rules for what yours does and doesn't like. For example, I avoid seafood unless I'm near the coast, where the seafood is fresh instead of frozen. Partially to avoid getting sick, but mostly because I grew up in a port city with world-class salmon, crab, etc. and I've become a snob about that kind of thing. When in doubt, err on the side of caution. But remember that trying local food is one of the best parts of traveling, so don't miss out just because you're paranoid about a tummy ache. Bon Appetit!