Warning: MySQL server has gone away query

WE ARE BACK!
After some time offline, finally our site is back. God willing, we've solved one of our greatest problems with Drupal at that was the Warning: MySQL server has gone away query: issue. You know.... that very annoying blue or white page filled with gibberish about error with MYSQL and then some.
At first I thought that Drupal couldn't handle more than say 8 modules before doing is error page on me, but then I found out from the Drupal forums itself that it was due to the short connection time to the MYSQL database that causes this issue. Here's the solution from Ilia Penchev, member at Drupal.org:
I am posting here the 2 possible solutions for anybody who has the same problem, I hope this will be of help to somebody :
1. Quick approach (not recommended since it will leave you with no module update information)
Just go to Admin -> Site Building -> Modules and disable the 'Update status' module. Voala :) No more nasty MySQL warnings and error messages.Anyway you will be left without actual information on any new updates or new major versions for your Drupal and modules.
2. The real fix (requires hacking of 2 Drupal core files)
Here is the real solution, it will require you to get hands dirty, but will fix your problem.First make a backup of these two files - just download them to some directory so you have them just in case:
includes/database.mysql.inc
includes/database.mysqli.incNow you need to edit these two files (I edit them directly on the FTP server, but you can make additional copies locally, edit them, save and then upload back)
Add the following lines of code (on a new line, as explained):
In includes/database.mysql.inc, at the end of function db_connect(), under the "SET NAMES" line:
mysql_query('SET SESSION wait_timeout = 60', $connection);In includes/database.mysqli.inc, at the end of function db_connect(), under the "SET NAMES" line:
mysqli_query($connection, 'SET SESSION wait_timeout = 60');Now you should get no more MySQL errors.
If you increase the number of istalled modules on your Drupal you may need to increase the timeout from 60 to a bigger value, for example 90, but I seriously doubt it will be ever needed.The idea of all this is that the update module will require more and more time to check for updates for the increasing number of installed modules on your Drupal site. At some point this time will exceed your server's default value for timeout and this causes MySQL "server gone away" errors.
On many webhosting companies' servers this timeout is set to a very low value (too conservative) and that's why so many people are facing this problem.
I hope this solves the problems for all our Drupal brethren out there. Have fun!!


