Jump to content

Recommended Posts

Posted

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.

 

Here's the code...

 

>$setmaxexectimeresult = ini_set(max_execution_time,600);
$uploadsizeresult = ini_set(upload_max_filesize,20240); //20 megabytes

 

and then later on...

 

>echo "[" . $setmaxexectimeresult . "] [" . $uploadsizeresult . "]";

 

...which returns...

 

><!--set result: [30] []-->

 

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?

Posted

Okay, update:

 

I discovered that ha, yes, I can set that in .htaccess, and apparently I can't within a script. Duh. Okay. Got that working.

 

Now, it says that my problem's with the MAX_FILE_SIZE in the HTML code. Here's what I have:

 

><input type="hidden" name="MAX_FILE_SIZE" value="20M"><input type="file" name="media" id="media">

 

Hmm... what's wrong?

Posted

One of the quick searches I just did references the following,

 

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

 

I am sure there is a work around for this I am just not sure if this is your problem or not..

have you tried uploading files less than 2 meg ?

Posted

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.

 

Okay, I decided to get rid of the MAX_FILE_SIZE field. Not needed.

 

So, I come across another error:

 

>Got a packet bigger than 'max_allowed_packet'

 

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?

Posted
I am sure there is a work around for this I am just not sure if this is your problem or not..

have you tried uploading files less than 2 meg ?

Yeah, I've tested it with smaller files and it works fine.

Posted

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_filesize 2M 2M

><?php
phpinfo();
?>

what makes you think that the error message your seeing is from MySQL ?

did you print out the mysql_error() ?

Posted
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_filesize 2M 2M

><?php
phpinfo();
?>

what makes you think that the error message your seeing is from MySQL ?

Yes, I know that the PHP max_upload_size is 2M by default. I was trying to change that. :)

 

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.

Posted

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 :)

 

Tnagentidea, as for your problem with MySQL, the MySQL manual says:

A communication packet is a single SQL statement sent to the MySQL server or a single row that is sent to the client.

 

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.

 

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. [...]

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 :(

Posted

TCH-Raul thanks for the information on this.

 

TangentIdea , to get around this issue how about just add a link into the MySql Database referencing a file located in a folder ?

might be a way around trying to load an entire BLOB into the database.

Posted

Yes, I agree.

I forgot to mention that!

 

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.

 

Besides, in your case, as rmulhern said, it would be a way to get around this issue :)

Posted

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. :)

Posted

Yes, it's easier, but in the long run, I think (actually, I know; been there, done that...) that method brings more problems :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...