You may be violating the max_allowed_packet
setting. See here for more data.
Quote,
If you are using the mysql client program, its default
max_allowed_packet variable is 16MB.
If you are uploading uncompressed images, this value is fairly easy to reach.
Also, it would be great if you could name the specific database interface class that you use (PDO? mysql_? mysqli_?), as different classes handle errors differently. It could just as well not handle an oversized packet situation at all.
P.S.: You should really be checking your logs for the specific error you encounter. The first place to look for would be /var/log/mysql/error.log
(could vary depending on your env)
Update:
mysql_error()
returned "MySQL server has gone away"
From the manual pages for the error: "You can also get these errors if
you send a query to the server that is incorrect or too large. If
mysqld receives a packet that is too large or out of order, it assumes
that something has gone wrong with the client and closes the
connection. If you need big queries (for example, if you are working
with big BLOB columns), you can increase the query limit by setting
the server's max_allowed_packet variable, which has a default value of
1MB. You may also need to increase the maximum packet size on the
client end..."
(quote courtesy of @Colin Morelli)