I have back pain on right side below ribs. I've taken pain pills for years... could this be related?
Taking pain pills in themselves should not cause say back or shoulder pain. It is possible, paradoxically enough, for some people on narcotic pain relievers to become more sensitive to pain. If this was to occur you might start having pain in areas where you don't have a significant injury.
The more likely reason for your pain is that you've strained something in that area. Muscle strains are the most common reason for pain and they usually take several weeks to subsides. Several muscle groups run inside and around the ribs making them a good candidate for unexpected muscle strains. You could have also injured your back in some way.
In general if a moderate pain is not getting better after a week or two (and is not accompanied by other symptoms) its probably time to see a doctor. Only a doctor can accurately diagnose what's going on with you. Good luck!
Here are some links that might be helpful to you:
Let's Talk Pain Meds
What Can Be Done About Nerve Pain?