Hey everyone this issue is giving me gray hair, last week this was all working fine, Monday when I get into work and try running another test it starts failing.
Backround: I am building a utility for work that will allow the video guys to either upload a file from their system or specify the URL of a video whether it be in Amazon S3 or wherever. The utility will then either upload the video store it and put an entry in the DB to keep track of it, or move it from the URL provided to the dir they are being stored in and do the same with the mysql.
The Issue: It has recently became an issue where when moving from a URL I get an error stating that the "MySQL Server has gone away" lots of searching has ended up with lots of issues on timeouts, packet size etc. But, the MySQL connection isn't even being opened until after the file has been moved into its directory. When moving a file from a URL I get the error in under 10 seconds. The only tests I can get to go through is when I specify a URL of a file that is really small, like 5mb.
Last week I was able to run successful tests on files up over 500mb (pulling from URL). Now the files will still move over, but I get the server has gone away error.
Here is the code I am using
file_put_contents('vid_bin/'.$fName, fopen($url, 'r'));
$qry = "INSERT INTO videos (".$fields.") VALUES (".$vals.")";
$db = new mydb;
$db->mydb; //connects
$db->select_db("thedbname"); //selects db
$db->query($qry); //runs query
if($db->error) {
die($db->error . "\n". $qry); //oh noes
} else {
...
}
Our server guy hasn't been available so I am left wondering if its my code or if its something that changed on the server. I am pretty sure its not the code but wanted outside opinions on what could be causing MySQL to freak out despite only having strings, dates and ints stored in it.
UPDATE: If I process the MySQL bits before messing with the file all works well. The problem is, I have the file handling bit of code in a try/catch because if someone provides an invalid URL or something goes haywire I don't want to go back and remove the MySQL record.
Any idea why MySQL would care if the file is handled before it? I was thinking it might have something to do with packet size in the MySQL config but I am not storing the file in the db. Looks like it is going to be an issue for the Server admin to handle, unless someone has some insight into why this would be happening from the code end of things.