I had the same problem with my iPhone 4. I tried blowing on the SIM as well as trying a new one but still had the problem. I just took the phone into an Apple store and they replaced it with a new one. I've not had the problem since.
Does the cell data have to be turned on to see a sim number in settings?in other words does it say no sim in settings when cell data is off? I am just checking since mine doesn't show a number and I am getting ready for a trip in a couple of days, and I want to make sure it is stll working before I leave.