General emergencies

The Public Security Bureau (i.e. Police) in Shanghai maintains a hotline for foreigners if they run into trouble.  The person who answers the phone supposedly understands and speaks English.  The number is 021 63576666. 

Shanghai police offers English service as well. Dial 110 and once you hear the operator say "English please" and wait until they put an English speaking officer into the line who will then translate for the Chinese operator. Shanghai police is generally very helpful towards foreigners and you should absolutely not hesitate to call them when really needed.

Most western consulates have after-hour emergency numbers (which is usually a mobile phone the duty officer takes home for the night).  Check the website of your consulate for that number before you go.

Medical emergencies

Be aware that if you encounter a medical emergency, ambulance service is slow and unreliable, and they often demand payment in cash (about RMB 199) up front before they will transport you. Also ambulances are by no means comparable to what Westeners are used to when it comes to equipment and medical education of the staff. It's better to take a taxi to the emergency room.

The United States consulate provides a list of medical facilities with English speaking staff. Note that all of them also have Western prices which need to be paid after the consultation - so take your credit card with you.