Solved

Hitting the POST variable limit

Posted on 2014-03-14
16
316 Views
Last Modified: 2014-03-25
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?
0
Comment
Question by:sgaggerj
  • 4
  • 3
  • 3
  • +4
16 Comments
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 83 total points
ID: 39929494
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
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 83 total points
ID: 39929526
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.
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 83 total points
ID: 39929709
Are all fields going to be changed?
This sounds like a case for ajax and just update the fields as they are changed
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 83 total points
ID: 39929766
On the different hosting companies I use, I find the "post_max_size" in 'php.ini' set to 8M, 25M, 33M, and 108M.
0
 
LVL 56

Assisted Solution

by:Julian Hansen
Julian Hansen earned 83 total points
ID: 39929856
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.ini

post_max_size=XXM
upload_max_filesize=XXM

.htaccess

php_value post_max_size XXM
php_value upload_max_filesize XXM
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39929869
The number of fields should not be relevant
Unless your host has Suhosin installed.  Suhosin usually limits the number of fields to 1000.
0
 
LVL 1

Author Comment

by:sgaggerj
ID: 39929948
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.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39929971
With AJAXyou would only submit fields as they are changed, you wouldn't be submitting the whole form.
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 83 total points
ID: 39930257
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? ?
0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 39930269
Does the limit apply if you use arrays?
0
 
LVL 1

Author Comment

by:sgaggerj
ID: 39930434
@slick812

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.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39930453
There are still methods to only submit smaller parts that have changed instead of the whole table.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39930594
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.
0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 39930925
Have you considered using AJAX updating - after editing only those fields that have changed a are updated through AJAX?
0
 
LVL 1

Accepted Solution

by:
sgaggerj earned 0 total points
ID: 39937500
@ 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.  

Thanks!
0
 
LVL 1

Author Closing Comment

by:sgaggerj
ID: 39952705
Used my own solution stated in my post above this.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to count occurrences of each item in an array.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question