maximum number of $_POST items (not max size)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KathyBerman
Forum Newbie
Posts: 4
Joined: Fri Apr 27, 2012 10:00 am

maximum number of $_POST items (not max size)

Post by KathyBerman »

I have a script with about 1500 textareas (it is a selfmade po editor for inside a php program).
I get a "server hiccup" and headers problem, which is resolved if I considerably limit the number of textareas.
There seems to be a limit on the number of $_POST items that can be send.
It is not a size problem (the total size of all posts together is 100K!) and the problem occurs even when all textareas are empty.
In other words it is the number of items, not the size.
I can't find anything on the web. All explanations are about setting the maximum size of $_POST and that is not the problem.
Does anyone know what can be done about it. I am on a server with a paid webhost, ie I can not directly change Apache settings, just php.ini and some .htaccess settings,
Thanks,
Kathy
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: maximum number of $_POST items (not max size)

Post by Celauran »

I just created a dummy form with 2000 textareas and it worked fine. Must be something else at play here. Can you please provide more information about the errors you're encountering?
KathyBerman
Forum Newbie
Posts: 4
Joined: Fri Apr 27, 2012 10:00 am

Re: maximum number of $_POST items (not max size)

Post by KathyBerman »

Sorry I forgot to mention that the problem occurs when each text area has its own specific name. (dynamically generated)
If they have the same name there is no problem, but the moment they get a name attr then things go wrong.
Kathy
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: maximum number of $_POST items (not max size)

Post by x_mutatis_mutandis_x »

KathyBerman wrote:Sorry I forgot to mention that the problem occurs when each text area has its own specific name. (dynamically generated)
If they have the same name there is no problem, but the moment they get a name attr then things go wrong.
Kathy
I don't have a problem either (2000 textareas) even with dynamically generated names. Make sure the HTML for your text area is '<textarea name=""></textarea> and not <textarea name="" />. I know I used to make that mistake a lot :P

If you are still getting errors, then show us your HTML and PHP code.
KathyBerman
Forum Newbie
Posts: 4
Joined: Fri Apr 27, 2012 10:00 am

Re: maximum number of $_POST items (not max size)

Post by KathyBerman »

Thanks for your replies so far.
I will show here a simple php test file that I called testta.php, which creates the same error as my much more complicated real script:

Code: Select all

<?php
if(isset($_POST['test'])) {
    echo 'The textareas were posted successfully!<br>';
}
$max = 1500;
echo '<form action="testta.php" method="POST">';
echo '<input type="submit" name="test" value="Submit"><br>';
for($i=0; $i < $max; $i++) {
    echo '<textarea name="test'.$i.'">name is test'.$i.'</textarea><br>';
}
echo '</form>';
?>
The error message generated in the browser:
[text]500 Server Error: A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.[/text]
From the Apache log file:
[text][Sat Apr 28 12:47:48 2012] [error] [client 93.172.175.50] Premature end of script headers: testta.php, referer: http://*****/******/testta.php[/text]
I have also tried out and found that if $max is set to up to 999 textareas the script works fine. The moment I make the number 1000 and up, I get the errors.
So the limitation is: no more than 999 textareas. Any ideas what setting could cause this?

Thanks in advance,
Kathy
Last edited by KathyBerman on Sun Apr 29, 2012 6:34 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: maximum number of $_POST items (not max size)

Post by requinix »

Obviously 1000 is too nice of a number to be a coincidence. Can you put up a phpinfo page? Also, how much do you know about how PHP is set up? Have you asked bluehost for advice?
KathyBerman
Forum Newbie
Posts: 4
Joined: Fri Apr 27, 2012 10:00 am

[SOLVED] Re: maximum number of $_POST items (not max size)

Post by KathyBerman »

requinix,

Thanks, I had a good look at the phpinfo information and saw that max_input_vars is set to 1000.
Setting it to 2000 in php.ini solved my problems.
Thanks for pointing me in the right direction.

Kathy
Post Reply