I used to have my old iPhone 3GS pick up our wireless with no problems. at all But since I've bought a new iPhone 3GS -- after I tipped a cup of tea over my old one -- it won't let me pick up the wireless. It won't even let me punch in the password; it keeps saying "unable to join network".
go into 'settings' then 'wi-fi'. make sure wi-fi is 'on' and select the relevant network, then enter any password etc for it. It should now automatically connect you when you are in range.
I had a similar problem on mine recently. The apple help page suggested going into wifi and turning it off then turning it back on again. Soon as I Kidd that it let me enter a password and connected.