Problem with uploading to database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anshuverma1989
Forum Newbie
Posts: 13
Joined: Sat Jan 10, 2009 2:21 pm

Problem with uploading to database

Post by anshuverma1989 »

Hello,

I am facing this problem while uploading a big file to my database.

The problem i am facing is that when i upload a big file like more than 1 MB.. it does not upload the file and shows the following error.

"Failed to execute SQL. Error: MySQL server has gone away"

This is my table structure

Code: Select all

CREATE TABLE tbl_Files (
id_files tinyint(3) unsigned NOT NULL auto_increment,
bin_data longblob NOT NULL, <<< this is where the files gets uploaded
description tinytext NOT NULL,
user_name varchar(50) NOT NULL,
subuser_name varchar(50) NOT NULL,
PRIMARY KEY (id_files)
);
what should i do?

please solve my problem..

thanks and regards,
Anshu
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Problem with uploading to database

Post by mattpointblank »

First google result for your error is this: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

One of the points says:
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. More information on setting the packet size is given in Section B.1.2.10, “Packet too large”.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Problem with uploading to database

Post by aceconcepts »

I typed the error you quoted into Google and voila there is information on this topic.

http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

Try searching for your solution.
Post Reply