My IPhone does the same thing. I use my IPhone 24/7. I think it's something to do with the location and how many bars you have. Sometimes when my phone has 3 bars, it says no Internet connections so I have to move to another location and when I have more bars it works.
It depends on what you are seeing on the top. If you are showing that it has a wireless signal it is a most likely problem with the your network. If you have a "E" showing, at least in my area, the Edge network is not sufficient to access the net. Finally if you have the "3G" showing it's the phone kind of getting lost to the network for various reasons - TO FIX: you must reinitialize your phone on the network. 2 ways to do this is, 1. Turn off/on phone Or 2. Open settings and turn on Airplane Mode then back off again. This is the quickest way.