Jump to content

Certain File uploads causing "MySQL Server has gone away errors"


2levelsabove

Recommended Posts

I have a PHP page that uploads files and then inserts into a table the name of the file that was uploaded.

 

 

I recently changed servers and find myself in a situation where certain files would cause MySQL server to go away. I out put the insert query and when I paste that on MYSQL console, it seems to insert that fine. The uploaded files that cause the "MySQL server has gone away error" vary in size anywhere from 512 K to 4 MB so size of the files doenst seem to be causing any problems.

 

 

Even if i do a mysql_ping(0 right before the query and try to reconnect the database upon failure, the insert query just does not go through. But as I mentioned before, i am able to manually paste the same query in MySQL console windows and it inserts fine.

 

by the way this is my query

 

         INSERT INTO             prFile
               (
                                               ProjectID
                                       ,       FileName
                                       ,       FileLoc
                                       ,       SortOrder
                                       ,       DateUploaded
                                       ,   FilePath
                                       ,   ThumbnailPath
                                       ,   NumPages
               )
               VALUES
               (
                                                212
                                       ,       'p1012434.jpg'
                                       ,       'p1012434.jpg'
                                       ,        1
                                       ,        NOW()
                                       ,    '/home/test/public_html/user/15/4e0738b2cae1beac2f82371f56a8864c/files/p1012434.jpg'
                                       ,    '/home/test/public_html/user/15/4e0738b2cae1beac2f82371f56a8864c/files/tn/p1012434.jpg'
                                       ,     1
               )



 

 

 

 

I am totally lost in this and would appreciate some insight.

 

 

Is the MySQL server on the same server as the web server? Also, when are you connecting to the database? If the script is taking a long time and you have opened the mysql connection at the beginning, the server could be timing out. You should try to move your mysql_connect close to the sql string.

Ok it is PHP causing the problem.

 

The following line seems to mess up the MySQL connection.

 

 

$docPageCount=getPDFPageCount($uploadFile);//this function gets the number of pages from PDF

 

 

function getPDFPageCount ($filePath = '') {
	$retval = 1;



	$bin = '/usr/bin/pdf2ps -sOutputFile=- '.$filePath.' | grep -c "%%Page: "';

	//error_log($bin,1,"[email protected]");


		$cmd = "{$bin}";
		$retval = shell_exec($cmd);


	return $retval;
} // getPDFPageCount

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.