This error often occurs when MySQL times out because the query's taking too long.
At a guess this would be at the MySQL end of things - try running this command at the mysql prompt: SHOW VARIABLES LIKE 'wait_timeout'; You should get something like this: +---------------+----------+ | Variable_name | Value | +---------------+----------+ | wait_timeout | 28800 | +---------------+-----------+ 1 row in set (0.00 sec) Where Value is the number of seconds. You can override this by issuing this command: set wait_timeout = $largernumber More reasons for this error are here: http://dev.mysql.com/doc/mysql/en/gone-away.html --Simon