iPhone "No SIM" problem

I recently upgraded my UK O2 provided iPhone to a 3G model, and we bought an O2 pay-monthly SIM to put in my "old" iPhone that was freed up as a result of the upgrade.

However, while it would work sometimes, at other times it would display "No SIM" at the top left, and pop up a message saying "No SIM card is inserted".  We would restart it, and it would be fine for a short while, and then "No SIM" again.

This was very annoying, and I spent a long time trying to figure out what the problem was.  Two restores, a lot of removal and re-insertion of the SIM card, and a certain amount of Googling did not provide a solution.

The answer turned out to be as follows.  On the phone, I went into the Settings applet, then:

General -> Reset -> Reset Network Settings

This has completely cured the "No SIM" problem, and it's run very smoothly ever since.