2

我收到此错误

不能接受的

在此服务器上找不到请求资源 /admin/prc_res.php 的适当表示。

此外,在尝试使用 ErrorDocument 处理请求时遇到 406 Not Acceptable 错误。

有一个$_POST['additionalinfo'](来自 html teaxtarea)给了我这个错误。如果我删除它,代码就可以正常工作。

但是为什么我会406出错?

我在 unnat1ir.in/cdn/ 中的 index1.php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>406 Error</title>
</head>
<p><form method="post" action="process.php">
<textarea name="test" rows="10" style="width:100%"></textarea><br>
<button type="submit">Check for 406 Error</button>
</form>
</p>
<p>This form is posted to <code>process.php</code>. In <code>process.php</code> I am just echo-ing <code>$_POST['test']</code> of the <code>textare with tinymce plugin</code>. <strong>If little amount of data is entered in textarea, no issues, BUT LARGE DATA will cause <code>406</code> error</strong></p>
<h1>Please check by inserting large <code>html</code> data </h1>
<body>
</body>
</html>

和process.php

<?
ini_set("log_errors", 1);
ini_set("error_log", "err.txt");
?>
<h1>The <code> echo ($_POST['test'])</code> is</h1>
<hr>
<code><? echo htmlentities($_POST['test']); ?></code>
<hr>

以上所有代码都可以正常工作localhost

4

6 回答 6

1

这是因为您没有转义通过文本区域字段(如引号等)输入的一些 html 字符。请尝试下面的代码。

mysql_escape_string($_POST['additionalinfo']);
于 2018-04-28T19:41:07.123 回答
0

这应该是你的php.ini配置的问题,尝试编辑

post_max_size=80M或增加限制的东西。

于 2017-03-08T07:10:37.990 回答
0

尝试这个 :

<?
ini_set("log_errors", 1);
ini_set("error_log", "err.txt");
?>
<h1>The <code> echo (htmlspecialchars($_POST['test']))</code> is</h1>
<hr>
<code><? echo htmlspecialchars($_POST['test']); ?></code>
<hr>

了解更多信息

于 2017-03-08T09:12:10.317 回答
0

试试这个代码(见开始标签):

<?php
ini_set("log_errors", 1);
ini_set("error_log", "err.txt");
?>
<h1>The <code> echo ($_POST['test'])</code> is</h1>
<hr>
<code><?php echo htmlentities($_POST['test']); ?></code>
<hr>
于 2017-07-11T20:49:48.870 回答
0

我发现出现此错误是因为您试图插入“±”这种值。如果您删除此字符并提交表单,您的表单将成功提交。所以解决方案是你应该使用±而不是'±'这个符号或者你应该使用html符号代码然后只有你的信息保存到数据库中。

于 2017-07-11T20:21:56.660 回答
0

从它的声音来看,这已经解决了,但我想我可能会给你一些背景信息。

当服务器配置为拒绝满足或不满足某些条件的请求时,会发生 406 错误。

您的托管服务提供商可能正在修改它的 mod_security 规则,并且您的表单触发了 apache 的意外拒绝。

mod_security 规则可能非常复杂和复杂,因为它们通常配置在一行上。

如果您担心安全问题,您可能需要与您的主机核实他们是否为您的站点禁用了 mod_security 或者他们是否只是重新配置了它。

您可以通过上传一个名为phpinfo.php您的站点的文件来检查 mod_security 在您的站点上是否处于活动状态,该文件仅包含<?php phpinfo() ?>.

在浏览器中加载页面,然后搜索mod_security. 如果它在那里,那么他们只是修复了他们的 mod_security 配置。

如果没有,那么他们只是将其从您的网站中删除。

很高兴这得到了解决。

于 2017-03-14T19:41:12.110 回答