Okay, I'm having a major headache over this. I'm trying to insert MP3 files into a mySQL database, but I keep coming across an error of one kind or another. First it was a timeout, now it's filesize. I managed to use the ini_set command to successfully reset the max_execution_time var, but it's not working on the upload_max_filesize one.<br /><br />Here's the code...<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$setmaxexectimeresult = ini_set(max_execution_time,600);<br />$uploadsizeresult = ini_set(upload_max_filesize,20240); //20 megabytes<!--c2--></div><!--ec2--><br /><br />and then later on...<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->echo "[" . $setmaxexectimeresult . "] [" . $uploadsizeresult . "]";<!--c2--></div><!--ec2--><br /><br />...which returns...<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><!--set result: [30] []--><!--c2--></div><!--ec2--><br /><br />What's the deal? In the second pair of brackets, it should have a "2M" or something like that, to show that it was successfully reset. Aaand, it doesn't. I'm probably just missing something stupid -- any idea what?<!--content-->
Okay, update:<br /><br />I discovered that ha, yes, I can set that in .htaccess, and apparently I can't within a script. Duh. Okay. Got that working.<br /><br />Now, it says that my problem's with the MAX_FILE_SIZE in the HTML code. Here's what I have:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><input type="hidden" name="MAX_FILE_SIZE" value="20M"><input type="file" name="media" id="media"><!--c2--></div><!--ec2--><br /><br />Hmm... what's wrong?<!--content-->
One of the quick searches I just did references the following, <br /><br />Note that MAX_FILE_SIZE must be set to the maximum file size that you will allow users to upload. Also note that PHP's configuration limits this to 2 megs - no file greater than that may be uploaded with PHP<br /><br />I am sure there is a work around for this I am just not sure if this is your problem or not.. <br />have you tried uploading files less than 2 meg ?<!--content-->
Okay, now I'm feeling really stupid. I've been stumped on this for weeks, and I'm just now figuring it all out... sigh.<br /><br />Okay, I decided to get rid of the MAX_FILE_SIZE field. Not needed.<br /><br />So, I come across another error:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Got a packet bigger than 'max_allowed_packet'<!--c2--></div><!--ec2--><br /><br />From what I understood from PHP.net, this is a message generated by MySQL. Now what? How do I change this without having admin access?<!--content-->
<!--QuoteBegin-rmulhern+Dec 11 2004, 11:44 PM--><div class='quotetop'>QUOTE(rmulhern @ Dec 11 2004, 11:44 PM)</div><div class='quotemain'><!--QuoteEBegin-->I am sure there is a work around for this I am just not sure if this is your problem or not.. <br />have you tried uploading files less than 2 meg ?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Yeah, I've tested it with smaller files and it works fine.<!--content-->
if you put the following code on a page and upload it to your server and run it you will see that the Max file size for upload using php is set to upload_max_filesize2M2M<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />phpinfo();<br />?><!--c2--></div><!--ec2--><br />what makes you think that the error message your seeing is from MySQL ?<br />did you print out the mysql_error() ?<!--content-->
Also did you try adding this into your htaccess file:<br /> php_value upload_max_filesize 20M<!--content-->
<!--QuoteBegin-rmulhern+Dec 11 2004, 11:53 PM--><div class='quotetop'>QUOTE(rmulhern @ Dec 11 2004, 11:53 PM)</div><div class='quotemain'><!--QuoteEBegin-->if you put the following code on a page and upload it to your server and run it you will see that the Max file size for upload using php is set to upload_max_filesize2M2M<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />phpinfo();<br />?><!--c2--></div><!--ec2--><br />what makes you think that the error message your seeing is from MySQL ?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Yes, I know that the PHP max_upload_size is 2M by default. I was trying to change that. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><br /><br />I don't know for certain that it's from mySQL; it's just a hunch, from what I know from mysql.com and php.net.<!--content-->
rmulhern, 2MB is PHP default and the value used here on TCH's servers, it's not the maximum PHP can handle. As Tangentidea said, you can change that setting in .htaccess <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><br /><br />Tnagentidea, as for your problem with MySQL, the <a href="http://dev.mysql.com/doc/mysql/en/Packet_too_large.html" target="_blank">MySQL manual says</a>:<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->A communication packet is a single SQL statement sent to the MySQL server or a single row that is sent to the client.<br /><br />In MySQL 3.23, the largest possible packet is 16MB, due to limits in the client/server protocol. In MySQL 4.0.1 and up, the limit is 1GB.<br /><br />When a MySQL client or the mysqld server receives a packet bigger than max_allowed_packet bytes, it issues a Packet too large error and closes the connection. [...]<!--QuoteEnd--></div><!--QuoteEEnd--><br />It also says you can change that configuration option but you need to do so through MySQL's console or by changing it's configuration file. I don't think there's other way to do it and since we don't have access to any of those in a shared server environment, I'd say we're out of luck <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
Aaak. Okay, any ideas for workarounds?<!--content-->
I couldn't find any, sorry... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
TCH-Raul thanks for the information on this. <br /><br />TangentIdea , to get around this issue how about just add a link into the MySql Database referencing a file located in a folder ?<br />might be a way around trying to load an entire BLOB into the database.<!--content-->
Yes, I agree.<br />I forgot to mention that!<br /><br />This is a big topic of debate. My personal opinion is that placing the files outside the database is a better strategy, since it places less load on the database server, among some other reasons.<br /><br />Besides, in your case, as rmulhern said, it would be a way to get around this issue <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><!--content-->
Teamwork always a great thing......... Rock Sign<!--content-->
Yeah, that was plan B. I thought it might be easier for content maintenance to keep them in the database. That way, when I delete a record, it deletes the whole thing... but doing it with files should work fine. I'm just lazy. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Yes, it's easier, but in the long run, I think (actually, I know; been there, done that...) that method brings more problems <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Okay, update:<br /><br />I discovered that ha, yes, I can set that in .htaccess, and apparently I can't within a script. Duh. Okay. Got that working.<br /><br />Now, it says that my problem's with the MAX_FILE_SIZE in the HTML code. Here's what I have:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><input type="hidden" name="MAX_FILE_SIZE" value="20M"><input type="file" name="media" id="media"><!--c2--></div><!--ec2--><br /><br />Hmm... what's wrong?<!--content-->
One of the quick searches I just did references the following, <br /><br />Note that MAX_FILE_SIZE must be set to the maximum file size that you will allow users to upload. Also note that PHP's configuration limits this to 2 megs - no file greater than that may be uploaded with PHP<br /><br />I am sure there is a work around for this I am just not sure if this is your problem or not.. <br />have you tried uploading files less than 2 meg ?<!--content-->
Okay, now I'm feeling really stupid. I've been stumped on this for weeks, and I'm just now figuring it all out... sigh.<br /><br />Okay, I decided to get rid of the MAX_FILE_SIZE field. Not needed.<br /><br />So, I come across another error:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Got a packet bigger than 'max_allowed_packet'<!--c2--></div><!--ec2--><br /><br />From what I understood from PHP.net, this is a message generated by MySQL. Now what? How do I change this without having admin access?<!--content-->
<!--QuoteBegin-rmulhern+Dec 11 2004, 11:44 PM--><div class='quotetop'>QUOTE(rmulhern @ Dec 11 2004, 11:44 PM)</div><div class='quotemain'><!--QuoteEBegin-->I am sure there is a work around for this I am just not sure if this is your problem or not.. <br />have you tried uploading files less than 2 meg ?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Yeah, I've tested it with smaller files and it works fine.<!--content-->
if you put the following code on a page and upload it to your server and run it you will see that the Max file size for upload using php is set to upload_max_filesize2M2M<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />phpinfo();<br />?><!--c2--></div><!--ec2--><br />what makes you think that the error message your seeing is from MySQL ?<br />did you print out the mysql_error() ?<!--content-->
Also did you try adding this into your htaccess file:<br /> php_value upload_max_filesize 20M<!--content-->
<!--QuoteBegin-rmulhern+Dec 11 2004, 11:53 PM--><div class='quotetop'>QUOTE(rmulhern @ Dec 11 2004, 11:53 PM)</div><div class='quotemain'><!--QuoteEBegin-->if you put the following code on a page and upload it to your server and run it you will see that the Max file size for upload using php is set to upload_max_filesize2M2M<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />phpinfo();<br />?><!--c2--></div><!--ec2--><br />what makes you think that the error message your seeing is from MySQL ?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Yes, I know that the PHP max_upload_size is 2M by default. I was trying to change that. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><br /><br />I don't know for certain that it's from mySQL; it's just a hunch, from what I know from mysql.com and php.net.<!--content-->
rmulhern, 2MB is PHP default and the value used here on TCH's servers, it's not the maximum PHP can handle. As Tangentidea said, you can change that setting in .htaccess <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><br /><br />Tnagentidea, as for your problem with MySQL, the <a href="http://dev.mysql.com/doc/mysql/en/Packet_too_large.html" target="_blank">MySQL manual says</a>:<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->A communication packet is a single SQL statement sent to the MySQL server or a single row that is sent to the client.<br /><br />In MySQL 3.23, the largest possible packet is 16MB, due to limits in the client/server protocol. In MySQL 4.0.1 and up, the limit is 1GB.<br /><br />When a MySQL client or the mysqld server receives a packet bigger than max_allowed_packet bytes, it issues a Packet too large error and closes the connection. [...]<!--QuoteEnd--></div><!--QuoteEEnd--><br />It also says you can change that configuration option but you need to do so through MySQL's console or by changing it's configuration file. I don't think there's other way to do it and since we don't have access to any of those in a shared server environment, I'd say we're out of luck <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
Aaak. Okay, any ideas for workarounds?<!--content-->
I couldn't find any, sorry... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
TCH-Raul thanks for the information on this. <br /><br />TangentIdea , to get around this issue how about just add a link into the MySql Database referencing a file located in a folder ?<br />might be a way around trying to load an entire BLOB into the database.<!--content-->
Yes, I agree.<br />I forgot to mention that!<br /><br />This is a big topic of debate. My personal opinion is that placing the files outside the database is a better strategy, since it places less load on the database server, among some other reasons.<br /><br />Besides, in your case, as rmulhern said, it would be a way to get around this issue <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /><!--content-->
Teamwork always a great thing......... Rock Sign<!--content-->
Yeah, that was plan B. I thought it might be easier for content maintenance to keep them in the database. That way, when I delete a record, it deletes the whole thing... but doing it with files should work fine. I'm just lazy. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Yes, it's easier, but in the long run, I think (actually, I know; been there, done that...) that method brings more problems <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->