Jump to content

Archived

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

SammyP

[SOLVED] Post array size limit, but not MB

Recommended Posts

I have a form which has a variable size, depending on the number of rows in a table. For each row there are about ten fields, and I simply show them all for each row.

 

I've recently started having a trouble in that if I create a form with more than 400 elements, then the $_POST variable is truncated at 400. Is this normal? Do I have to limit the size of the $_POST array? Not by MB, which must be trivial for me, but for the number of array elements?

 

Share this post


Link to post
Share on other sites

I'm assuming your rows are like.. check boxes? if so.. just make pages.. like, PAGE 1 show

 

LIMIT 1,20

 

PAGE 2 show

LIMIT 21,20

 

PAGE 3 show

LIMIT 41,20

 

etc

Share this post


Link to post
Share on other sites

There is no limit on the number of elements. Also, if you were exceeding the post max size, the whole post array is empty. It is more likely that your form is invalid HTML or your form processing code has a logic error that is preventing it from operating on all the data. Have you examined the resulting html and/or validated the page at http://validator.w3.org/

Share this post


Link to post
Share on other sites

I agree with PFMaBiSmAd.  Out of curiosity I set up a test page with a bazillion inputs and it submits just fine no matter how many there are (albeit, very slowly).

Share this post


Link to post
Share on other sites

 

 

This thread sort of rings a bell. I going to take a wild guess and say that you have leading zero's on numbers (probably as array indexes) and since that results in them being treated as octal, at some point, you are getting either missing or invalid numbers.

Share this post


Link to post
Share on other sites

I agree with PFMaBiSmAd.  Out of curiosity I set up a test page with a bazillion inputs and it submits just fine no matter how many there are (albeit, very slowly).

 

Thanks to you guys for the comments, but I've checked and I really seem to have this limitation. I've added different numbers of input elements to the start of the form and everything happens in a way that suggests there is a 400 element limit to my post array.

 

Firstly, in my created HTML, there is no problem, the form looks as I'd expect. All of the elements are there.

 

In my processing, I now echo out the count of the Post array and it is always 400. If I add two dummy elements near the start, when I loop through the Post array the final two from the time before are not there.

 

Does anyone have any idea what might cause this? I don't want to go to the trouble of limiting the number of elements on the screen. (These are personal admin screens and I am not worried about how it looks.)

 

Sam.

 

(Like the quote flyhoney!)

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

I just tried this code

 

<?php
if (!isset($_POST['test0'])) {
$output = '<form name=test method=post>';
$string = <<<STRING
I have a form which has a variable size, depending on the number of rows in a table. For each row there are about ten fields, and I simply show them all for each row.
I've recently started having a trouble in that if I create a form with more than 400 elements, then the $_POST variable is truncated at 400. Is this normal? Do I have to limit the size of the $_POST array? Not by MB, which must be trivial for me, but for the number of array elements?
STRING;

for ($i=0;$i<500;$i++) 
	$output .= '<input type="hidden" name="test' . $i . '" value="' . $i . $string . '" />';

$output .= '<input type="submit" value="submit" /></form>';
echo $output;
}else {
echo '<pre>' . print_r($_POST, 1) . '</pre>';
}
?>

 

On my server and received 499 elements of the array. Which is correct.

 

I am not sure why your server is chopping it up, but yea. On a side note I believe there is a post_max_size variable in the php.ini file. Maybe try changing that to be larger than it is?

 

My setup is WAMP on Windows using FireFox 3 and yea it worked just fine. I also tested it with 1,000 items, still worked fine.

Share this post


Link to post
Share on other sites

I have found some information on this if anyone is interested. I ran phpinfo() and searched for 400.

 

It came up as a variable called suhosin.post.max_vars in some security module (Suhosin) my host company has installed. Set to 400 obviously.

 

So I've asked how to circumvent it and will do so if I can, and in case it helps I'll post out how I did it here. If it is possible at all.

 

Sam.

 

 

 

 

Share this post


Link to post
Share on other sites

So from here I had to implement my own php.ini files. It was an annoying bug, but it has been found now. Hopefully this will be of some use to anyone who has a similar problem.

 

 

Share this post


Link to post
Share on other sites

Thx for this help.

I've got the same problem and I've changed in suhosin.ini all "max"values... and now it's ok.

Share this post


Link to post
Share on other sites

Essential little thing you forgot to mention and I just experienced myself.

 

If you raise suhosin.post.max_vars you also need to make sure, that suhosin.request.max_vars is also raised to this new maximum, because otherwise it would overwrite the suhosin.post.max_vars.

I also raised max_input_vars from php to make sure really NOTHING keeps inputs from getting posted.

 

Code in vhost.conf (Plesk based ^^).:

php_admin_value suhosin.post.max_vars 5000
php_admin_value suhosin.request.max_vars 5000
php_admin_value max_input_vars 5000

Should work in .htaccess, too. But I have not tested it.

 

func0der

Share this post


Link to post
Share on other sites

×
×
  • 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.