I suggest getting to your doctor asap! I suffered from this and was told it was a muscle cramp. It was a burning, stabbing pain right under my ribs on the right side that radiated into my right shoulder blade. My attacks got worse and worse until I ended up in the ER. It was gall stones/gall bladder disease. I had to get it out. Felt great since then...
I treated my attacks with tums and mylanta or Maylox and a heating pad on my ribs. The heating pad worked wonders-- not sure how or why but it did. In the meantime stay away from fatty foods, eat low fat and stay away from dairy, nuts, chocolate and especially cheese... cheese is what landed me in the ER.
Good luck to you and I really hope it's something you can take care of easily and quickly. If you end up needing your gall bladder out if they can do it laproscopicly (sp?) it's a breeze...