Okay so what I did to fix the problem on the iPhone 4 when I couldnt get any sound from the earpiece speaker was this..
1) checked that the volume went up and down on the phone.
It did
As I did this I noticed the volume symbol going up and down on the screen said "Volume (Head Phones)" I didnt have the head phone in....
So the phone thinks I have the head phones in... explains why I cant hear anything when I put the phone up to my ear, the sound has been divered away from the internal earpeice speaker to the head phones (Well thats how it would work in my simple non electronic mechanical thinking way)
I tried turning the phone off and on... no change...
Okay what I am about to tell you next wont appear in any "How to fix your iPhone" Manual
With the iPhone on, I pushed a toothpick into the head phone socket. (A wooden tooth pick) and went up and down in the volume button. I jiggled the tooth pick around without much success... Then I scrapped the bottom of the head phone socket hole... and gave it a little soft push... up and down on the volume.... and what do you know... the word "Head Phones" was gone from the screen... phone started working again.
How long ago did I do this?... About 3 minutes ago. I was so excited that I might be able to help some one I got on and registered to let you know.