Hitting the POST variable limit

Hi Experts,

I have an admin page on a site I'm maintaining that displays the contents of a database table.

each row has 50 fields, and when the table is displayed on the admin page, every field is editable

right now i have it as part of a form, and on clicking submit, the database table is updated with the contents of the fields.

My issue comes in now that there are more than 20 rows (42 actually, totaling 2100 fields).

POST limits this to 1000 "fields".  I can't change the apache settings (it's hosted and they won't change it for me), and adding

php_value upload_max_filesize 12M
php_value post_max_size 32M

to the .httaccess file gives a 500 error.

Anyone have a brilliant suggestion on how to handle this?

I thought instead of having 2100+ 'inputs' in the form, of having only one input on the form: a very long string containing all the values of the table that i could pass as 1 post variable and parse as an array upon submit - using JavaScript to handle the changes as the user enters / changes data and writing that data to the string.

Any suggestions that are better than that?
Who is Participating?
sgaggerjConnect With a Mentor Author Commented:
@ Dave Baldwin:
Yep, that's what I ended up doing.
my form has 1 input (hidden) as a key.  Each entry in the displayed table when changed will add to the key in the form:  <id:value>;<id:value>..... that gets updated via JavaScript.
Then on submit that key is passed and parsed by my php script updating the db table.

@ Ray Paseur:
True, however he doesn't have alot of money to switch (nor do I honestly have the desire or the time to switch things for him nor get involved with his host).  Kind of have to work with what I have.

@  julianH:
Yea I looked at it real quick, but don't know AJAX at all to be able to implement it.  This is a side "job" helping out a friend and I don't have a ton of time to spend on it.

So the long and short of it is I figured it out, doing what I described above.

I really appreciate all of your input on this and will look at how to distribute points to everyone for their input.  

Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
there is a post size limit as well (I don't have the number off the top of my head right now) but you may run into that issue as well.

Depending on how much re-coding you want to do, you could turn the form into an ajax based form and save x amount of fields at a time, that way you could control the number of fields you pass across
Ray PaseurConnect With a Mentor Commented:
Find out if the host has Suhosin installed.  If they do, ask them to disable it.  There should be no practical limit on the number of POST input controls, and the overall limit of the POST request is somewhere near the 2 billion byte mark.  If your host can't fix this (it is their problem, not yours), consider getting a new hosting company.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

GaryConnect With a Mentor Commented:
Are all fields going to be changed?
This sounds like a case for ajax and just update the fields as they are changed
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
On the different hosting companies I use, I find the "post_max_size" in 'php.ini' set to 8M, 25M, 33M, and 108M.
Julian HansenConnect With a Mentor Commented:
The number of fields should not be relevant - what is relevant is the post size. Fields in a post are just a concatenated string - so the number should not matter.

However if you are hitting the limit on the post size you might need to increase it

There are two ways to do this - but your ISP might need to be involved to do this




php_value post_max_size XXM
php_value upload_max_filesize XXM
Dave BaldwinFixer of ProblemsCommented:
The number of fields should not be relevant
Unless your host has Suhosin installed.  Suhosin usually limits the number of fields to 1000.
sgaggerjAuthor Commented:
As far as I can tell I'm limited to 1000 post fields.  each row has two fields for text description and the other 48 are currency values (ie 0.00, 1.25, etc).  I've changed all the text descriptions to two characters each and was still limited to 1000 fields in $_POST[]

As far as the length of each field it's between 4 characters (0.00) and the length of a description (varies from line to line from 4 to 20)

I don't know ajax at all so that probably won't help me much.

I'll check with the hosting provider again and see what they can do.

I don't believe I have access to my php.ini file to change....

I may change the naming convention on each of the individual <input> tags, putting them outside my form, and use Javascript to create a string with what key => values were changed - rather than changing them all every time - and submit just that string on update.
With AJAXyou would only submit fields as they are changed, you wouldn't be submitting the whole form.
Slick812Connect With a Mentor Commented:
Just my way to deal with this, is to divide up large Data sets, presented to to the user on the page, Almost every one can work better with understandable amounts of  digital data (Rows or elements of page output), You say -"My issue comes in now that there are more than 20 rows", , so you might could put a display of 15 rows at a time, might solve the Max limit problem and be more user friendly? ?
Julian HansenCommented:
Does the limit apply if you use arrays?
sgaggerjAuthor Commented:

Part of my problem comes in due to the fact that the owner of this site wants all the rows visible in a scrollable form.

I think I came up with a solution which appears to be working.  

I have to test it out over the weekend.

I'll post back with results.
Dave BaldwinFixer of ProblemsCommented:
There are still methods to only submit smaller parts that have changed instead of the whole table.
Ray PaseurCommented:
owner of this site wants all the rows visible...
A reasonable request.  The owner should be willing to pay for a hosting company that can implement this without artificial limits.
Julian HansenCommented:
Have you considered using AJAX updating - after editing only those fields that have changed a are updated through AJAX?
sgaggerjAuthor Commented:
Used my own solution stated in my post above this.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.