How can I prevent my Wi-Fi connection from glitching?
This could be a solution, but it's more a hint at the issue:

The ZTE Blade suffers with losing it's Wi-Fi connection when it comes back from sleep. Perhaps you have a similar issue?
The app Blade Wifi Fix by AA Android available from Google Play Store, fixes it on the Blade, you could give it a try:


  Some people with the ZTE Blade / Orange San Francisco phone find that the Wifi doesn't always come back on after the phone wakes up from being locked or asleep.
  
  Install this and you wont know its there until you wake up your phone and the Wifi jams, at which point it will flash a message to tell you its fixing it.