iPhone 4 seems to have a wifi bug where it will disconnect from a wifi source and not reconnect to it.
Basically if you let the screen turn off and turn on the screen on again you will notice that the wifi was disconnected.
And here is the solution:
Instead of joining to an network you will have to choose Other and manually join onto a network.
This so far has solved the problem with wifi for me the past 2 days.
And I didn’t have to restore the phone.
Hope this helps.