Pain is a drain
Any pain, if strong enough, can cause disconnected, foggy feelings.
At least part of the reason is the release of neurohormones in response to pain which have negative effects on cognition and emotion
. Of course this answer assumes that you don't have a serious spinal or brain or head disorder.