16

I've got a questionnaire that went live over the weekend. After reaching so many entries PhpMyAdmin started showing this warning:

Warning: a form on this page has more than 1000 fields. On submission, some of the fields might be ignored, due to PHP's max_input_vars configuration.

The table is called survey and it has 10 columns and 300 rows of data - mostly strings. I don't get where its getting the number 1000 fields from? Everything was fine until the survey table got to about 150 entries. I'm worried I will lose my data.

My questionnaire comprises of 20 pages all with multiple choice questions. All values are stored in the $_SESSION array then sent to the DB on the 21st page.

PhpMyAdmin

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
user1574598
  • 3,771
  • 7
  • 44
  • 67
  • How should we know without seeing any code? – juergen d Dec 08 '14 at 19:12
  • Start by backing up your DB. – Funk Forty Niner Dec 08 '14 at 19:12
  • There is pages and pages of code - where do I start? Just starting to back up my tables – user1574598 Dec 08 '14 at 19:12
  • And what does PhpMyAdmin have to do with the actual application? – mario Dec 08 '14 at 19:14
  • 4
    _" I don't get where its getting the number 1000 fields from?"_ 10 x 300 = 3000 well over 1000. – AbraCadaver Dec 08 '14 at 19:16
  • It is PhpMyAdmin I am monitoring my data with - so far I have 300 entries and they are safe so far. So am I best backing up and wiping all my tables? – user1574598 Dec 08 '14 at 19:16
  • @user1574598 you don't need to worry about anything it's just phpmyadmin creates an input field for every row, your application doesn't have 1000 fields when you are posting it – Hmmm Dec 08 '14 at 20:12
  • Ahh - thank heavens! I was about to post that I have phpMyAdmin set to `show` 500 rows. I've literally just put it to 50 and the message does not appear. So this input field is a text box? So it definitely was me showing (10x300) 3000 cells of data? Its strange that it didn't cut me off and only let me see the first 100 entries (10x100). – user1574598 Dec 08 '14 at 20:19
  • How Many records are you trying to view at a time – NaveenThally Feb 19 '15 at 06:04
  • Below the table you can select all rows (phpMyadmin v 4.8.3) and if you click on an edit you will be able to submit form with inputs for all of cells. It will be problem if there is no limitation. – Ivan Ganchev Feb 20 '20 at 09:18
  • This is a duplicate question, max_input_vars is covered here too! https://stackoverflow.com/questions/10303714/php-max-input-vars – dustbuster Apr 23 '21 at 16:55

7 Answers7

11

You aren't going to lose data. This error message is specific to you trying to see the contents of the table and selecting too many rows at once. The number of columns in the table multiplied by the number of rows displayed should be below the value set for max_input_vars in your php.ini. By default this is set to 1000.

When you are working with your specific code, you shouldn't encounter this error UNLESS you try to do the same thing--display more than 1,000 "elements" from a returned query at one point in time. Do you really expect to do that? If so, then be smart about paginating your data and using LIMIT in your SQL query.

The data itself is safe. The only thing affected is PHP's ability to retrieve and output.

jcanker
  • 877
  • 8
  • 8
4

Use this configuration in a php.ini file:

max_input_vars = 100000;
veben
  • 19,637
  • 14
  • 60
  • 80
AR Bhatti
  • 41
  • 2
3

Go to php.ini then find max_input_vars in file and change to:

;max_input_vars = 1000

To

max_input_vars = 10000

Then restart your server.

It will help you guys works for me

Happy Coding!!

Rohit Chauhan
  • 356
  • 1
  • 14
  • Thanks for posting an answer, but please check whether the exact same change has already been posted in another answer (which is the case here) – Nico Haase Apr 21 '21 at 11:06
2

I just found that the new PHP doesn't have a decent default and the php.ini variable max_input_vars is commented out. I uncommented that variable and it worked. Even leaving it set at 1000.

Doug Wolfgram
  • 2,064
  • 4
  • 27
  • 42
2

The following line in php.ini worked for me:
By default the line to set max_input_vars will be commented.
Uncomment by removing ; preceding the statement, change the value from 1000 to 1000000 and save the file.
Then restart the Apache and MySQL.

; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 1000000

It will work like a charm!

greybeard
  • 2,249
  • 8
  • 30
  • 66
  • Thanks for posting an answer, but please check whether the exact same change has already been posted in another answer (which is the case here) – Nico Haase Apr 21 '21 at 11:06
1

Use this configuration in a php.ini file:

max_input_vars = 1000 to max_input_vars = 100000;

it works for me.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • Thanks for posting an answer, but please check whether the exact same change has already been posted in another answer (which is the case here) – Nico Haase Apr 21 '21 at 11:06
0
max_input_vars integer
    How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE 
    superglobal separately). Use of this directive mitigates the possibility of denial of 
    service attacks which use hash collisions. If there are more input variables than specified 
    by this directive, an E_WARNING is issued, and further input variables are truncated from
    the request.

http://php.net/manual/en/info.configuration.php#ini.max-input-vars

Basically "MAX_INPUT_VARS" limits the amount of input values that can be submitted in one go.

For some reason its saying there are over 1000 variables being submitted when you are submitting the data to your server.

To work around this either increase the limit in your php configuration or... change when you are saving the data. Such as every time they answer so many questions or when they finish answering a page submit the form.

Bioto
  • 1,127
  • 8
  • 21
  • Thanks - firstly how do you change the `max_input_vars`, secondly and more worryingly - after reading the documentation could my questionnaire be under threat? I only have one `name` text box field on my form and I have wrapped it in this function: `real_escape_string`. All the rest are radio buttons. – user1574598 Dec 08 '14 at 19:35
  • Your going to need to edit your php.ini file. For the security I would check out the following: http://phpsec.org/projects/guide/2.html – Bioto Dec 08 '14 at 19:37
  • Thanks - will have to have a good read about this as its over my head at the moment. I've found the `php` config on my `godaddy` server, but its not editable. Is this error likely to be occurring because there is over (10x300) 3000 cells on the PhpMyAdmin page, or when my users submit, there is over 1000 entries going into the DB. As I said, looking at my data, it seems as is should be - no missing fields or odd unhuman answers. I've edited my question to show you the error as it shows. – user1574598 Dec 08 '14 at 19:58