2levelsabove Posted July 16, 2008 Share Posted July 16, 2008 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. Link to comment https://forums.phpfreaks.com/topic/115064-certain-file-uploads-causing-mysql-server-has-gone-away-errors/ Share on other sites More sharing options...
DyslexicDog Posted July 16, 2008 Share Posted July 16, 2008 If the code you're using for the sql works fine at the server there must be a problem with the php code. Please post the php code you are having problems with. Link to comment https://forums.phpfreaks.com/topic/115064-certain-file-uploads-causing-mysql-server-has-gone-away-errors/#findComment-591726 Share on other sites More sharing options...
teynon Posted July 16, 2008 Share Posted July 16, 2008 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. Link to comment https://forums.phpfreaks.com/topic/115064-certain-file-uploads-causing-mysql-server-has-gone-away-errors/#findComment-591727 Share on other sites More sharing options...
2levelsabove Posted July 16, 2008 Author Share Posted July 16, 2008 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 Link to comment https://forums.phpfreaks.com/topic/115064-certain-file-uploads-causing-mysql-server-has-gone-away-errors/#findComment-591819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.