I was/am also having this issue. Somewhere in here, someone suggested blowing air into the dock connector. I did this, and my volume slider and sound came back. This phone replaced a phone that had been damaged by water. I checked for the liquid indicator once I started having the issues with the internal speakers (same issue as most... no volume slider, phone seemed to think it was always connected to a dock, no sound from speakers) To locate the indicator, look here iPhone and iPod: Liquid damage is not covered by warranty
My indicator was not tripped. That was two weeks ago. I have been having OK luck with the air, but was sick of not having sound when I wanted it. Now, I will explain why I brought up the indicator.
I took it to the genius bar today to have it replaced. They checked the device, and the indicator was tripped (probably from the condensation from the canned air) Well, this immediately voids the warranty. No ifs, ands or buts. I was ******. They took it in the back and could not find a single sign of damage or moisture, but still told me I would have to pay $199 for a replacement because the liquid indicator was tripped. I spoke to a senior manager, and he was just as useless as the tech.
Called Apple Care (without paying because I checked the box for an exception) 30 minutes with a support guy and 35 minutes with the lead supervisor. Again, nothing they can or will do with the indicator tripped.
So, to make a long story a little longer, check your indicator. If it is activated, you're screwed. If not, take it immediately to a Genius Bar and have them replace your phone. DO NOT BLOW AIR IN IT or, as one person suggested, USE ALCOHOL ON THE DOCK CONNECTOR (this will definitely trip the indicator.) Hope this helps some of you, and you are able to get new phones.
I believe it is a dock connector/hardware issue and not an iOS issue (even though I am hoping for the latter)
Good Luck.