i have a bad neck cramp from sleeping the wronge way

I need to know what to do to ease the pain

Three times in my life I have had a more severe neck cramp than usual, and when I went to a doctor about it, he said it was because I had an ear infection. Apparent ally that made it about 10 times more pain according to him. All o could do was slowly move my neck in the opposite direction while putting a hot or cold press on it. I believe it was a warm compress to soothe the muscles or cold if it is inflamed.