Watch the No Pain IS Gain online guitar lesson by Bruce Arnold from Guitar Physiology Survival Guide
The most important thing to remember when learning how to play the guitar is to stop if you experience pain. You are not a prize fighter. Never try to play through pain!
I usually say that if you experience any pain stop immediately and wait ten to twenty minutes to play again. If the pain comes back then you need to rest for a day. If you do something that causes immediate pain and this pain continues after you stop playing then usually icing the affected area once an hour for 10 to 20 minutes is your best way to stop inflammation.
Obviously if your pain continues you need to consult a physician. The idea behind this course is to make it so you never get to that point. In my 30 years of teaching I've never had a student develop any physical playing problems if they implement the "Home Base Technique."
Training yourself isn't easy and initially it will require you to be very vigilant, checking on your technique by using a mirror or video recorder.