# Attachment\_fu and mysql (server has gone away)

**URL:** <https://www.ruby-forum.com/t/attachment-fu-and-mysql-server-has-gone-away/156537>\
**Category:** Rails\
**Created:** [December 29, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-mysql-server-has-gone-away/156537 "2008-12-29T19:03:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [December 29, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-mysql-server-has-gone-away/156537/1 "2008-12-29T19:03:22Z")

</div>

I have a problem with my hosting “hostgator”

In my site i have a section for photos upload.  
For manage it i use attachment\_fu.  
In the action of upload i do some simple query.

If the file to upload is smaller than 1mb there isnt any problem

but if it is bigger than 1 mb about i receive an error:

mysql error server has gone away.

i wrote to hostgator. they responsed me with:

All MySQL connections open for more than 15 seconds are killed off once  
a minute. Your script needs to be modified so the MySQL connection is  
opened just prior to the query actually being run

How i can to open mysql connection only when i do query for this action?  
thanks
