i too had this problem a while ago with my iphone 4. after spending days around forums and all i almost gave up. but then accidently i came across the ringer/silent sbsettings toggle. nd it definitely saved me a %@*@ lot of money.
solution is if ur iphone is jailbroken, go to cydia.if not, jailbreak and install cydia.install sbsettings thru cydia. and after u have installed sbsettings, search for ringer/silent sbsettings toggle. it wil work miracle :)