The most common reason for seeing Server has gone away error is your MySQL queries timing out. That can happen if you are using heavy or very long MySQL queries. Please try using mysql_reconnect command before each query.
In case you are still seeing such errors, we would recommend looking for help on websites like StackOverflow, where thousands of web development professionals share their knowledge!