Drink only bottled, boiled, or purified water and drinks; don't drink from public fountains or ask for beverages with ice. You should even consider using bottled or boiled water to brush your teeth. Make sure food has been thoroughly cooked and is served to you fresh and hot; avoid vegetables and fruits that you haven't washed (in bottled or purified water) or peeled yourself. If you have problems, mild cases of traveler's diarrhea may respond to Imodium (known generically as loperamide) or Pepto-Bismol. Be sure to drink plenty of fluids; if you can't keep fluids down, seek medical help immediately. Make sure the water bottle is sealed when you buy it.
Specific Issues in China
At China's public hospitals, foreigners need to pay fees to register, to see a doctor, and then for all tests and medication. Most doctors at public hospitals don't speak English, and hygiene standards outside of the major cities can be low.
The best place to start looking for a suitable doctor is through your hotel concierge. If you become seriously ill or are injured, it is best to fly home, or at least to Hong Kong, as quickly as possible. In Hong Kong, English-speaking doctors are widely available.
If you need to buy prescription drugs, try to go to the pharmacies of reputable private hospitals or to bigger chain stores like Watsons.
Most pharmacies in big Chinese cities carry over-the-counter Western medicines and traditional Chinese medicines. You usually need to ask for the generic name of the drug you're looking for, not a brand name. Acetaminophen—or Tylenol—is often known as paracetomol in Hong Kong. In big cities reputable pharmacies like Watsons are always a better bet than no-name ones.