警告:此页面上的表单有 1000 多个字段 PHP MySql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27365148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Warning: a form on this page has more than 1000 fields PHP MySql
提问by user1574598
I've got a questionnaire that went live over the weekend. After reaching so many entries PhpMyAdmin started showing this warning:
我有一份在周末上线的问卷。到达这么多条目后,PhpMyAdmin 开始显示此警告:
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.
警告:此页面上的表单有 1000 多个字段。提交时,由于 PHP 的 max_input_vars 配置,某些字段可能会被忽略。
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.
该表被调用survey
,它有 10 列和 300 行数据——大部分是strings
。我不明白它1000
从哪里获取数字字段?一切都很好,直到survey
桌子上有大约 150 个条目。我担心我会丢失我的数据。
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.
我的问卷共有 20 页,全部带有多项选择题。所有值都存储在$_SESSION
数组中,然后发送到第 21 页上的数据库。
回答by jcanker
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.
您不会丢失数据。此错误消息特定于您尝试查看表的内容并一次选择过多行。表格中的列数乘以显示的行数应低于 php.ini 中为 max_input_vars 设置的值。默认设置为 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.
当您使用特定代码时,除非您尝试执行相同的操作,否则不应遇到此错误——在某个时间点显示来自返回查询的 1,000 多个“元素”。你真的希望这样做吗?如果是这样,那么在对数据进行分页并在 SQL 查询中使用 LIMIT 时要明智一些。
The data itself is safe. The only thing affected is PHP's ability to retrieve and output.
数据本身是安全的。唯一受影响的是 PHP 的检索和输出能力。
回答by Doug Wolfgram
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.
我刚刚发现新的 PHP 没有合适的默认值,并且 php.ini 变量 max_input_vars 被注释掉了。我取消了该变量的注释,它起作用了。即使将其设置为 1000。
回答by AR Bhatti
Use this configuration in a php.ini
file:
在php.ini
文件中使用此配置:
max_input_vars = 100000;
回答by Rohit Chauhan
Go to php.ini then find max_input_vars in file and change to:
转到 php.ini 然后在文件中找到 max_input_vars 并更改为:
;max_input_vars = 1000
To
到
max_input_vars = 10000
Then restart your server.
然后重启你的服务器。
It will help you guys works for me
它会帮助你们为我工作
Happy Coding!!
快乐编码!!
回答by Bioto
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
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.
基本上“MAX_INPUT_VARS”限制了可以一次性提交的输入值的数量。
For some reason its saying there are over 1000 variables being submitted when you are submitting the data to your server.
出于某种原因,它说当您将数据提交到服务器时,将提交 1000 多个变量。
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.
要解决此问题,请增加 php 配置中的限制,或者...在保存数据时进行更改。例如每次他们回答这么多问题或完成回答页面时提交表单。