SammyP Posted December 29, 2008 Share Posted December 29, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/ Share on other sites More sharing options...
RussellReal Posted December 29, 2008 Share Posted December 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-725751 Share on other sites More sharing options...
PFMaBiSmAd Posted December 29, 2008 Share Posted December 29, 2008 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/ Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-725756 Share on other sites More sharing options...
flyhoney Posted December 29, 2008 Share Posted December 29, 2008 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). Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-725760 Share on other sites More sharing options...
PFMaBiSmAd Posted December 29, 2008 Share Posted December 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-725767 Share on other sites More sharing options...
SammyP Posted December 31, 2008 Author Share Posted December 31, 2008 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!) Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-727126 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-727174 Share on other sites More sharing options...
SammyP Posted January 2, 2009 Author Share Posted January 2, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-728200 Share on other sites More sharing options...
SammyP Posted January 11, 2009 Author Share Posted January 11, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-734408 Share on other sites More sharing options...
mykoze Posted September 26, 2011 Share Posted September 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-1272833 Share on other sites More sharing options...
func0der Posted August 5, 2013 Share Posted August 5, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/138796-solved-post-array-size-limit-but-not-mb/#findComment-1443549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.