you are most likely getting the 'connection failed' because you are trying to connect to an open network that you are not authorized to use, .... for example when you search for networks your phone will list all the networks within range ... you then select an open network such as BT OPENZONE .... however there is a problem here because BT OPENZONE is not actually an open network .... it's an unsecured network in that no passcode is required to access it however you do need to be a BT customer in order to use it (account info needs to be entered to get access), this will apply to other networks as well such as O2 networks.
networks used in pubs etc (most pubs use 'the cloud' (now owned by sky) as their service provider) are unsecure networks that can be accessed by anyone however you have to first pay for access and will be directed to the payment page upon connection to the network
Its actually quite hard to find free wifi although some hotel do provide it so you could try a few .... however whenever i want to connect for free i find that a wetherspoons pub to be great as they offer free wifi (and i can have a nice pint of real ale too) some of the McDonalds restaurants (if you can call them that

) also offer free wifi