My daughter's phone had the same problem. Open your back cover carefully, watch out for some pieces falling out! You will see the camera lens and 2 small rectangles next to it. Hopefully they will have 2 little rocker switches. From your problem I would think 1 or 2 of them have fallen out. The one closest to the lens is the "lens slider" detector. The one further away is the "back cover off" detector. Both have 2 metal contacts inside.
My daughter's phone is missing the "back cover off" detector. As the rocker was missing, the phone thought the back cover was off and so would not let the camera work (as you have the cover off to change either the SIM, battery, M2 card). When I jammed in some wire to make a permanent connection between the contacts the camera worked, i.e. opening the lens slider I could use the camera.
Hope that helps
Darren