PHP - Not Acceptable - 406 - file could not be found on this server

A B Catella picture A B Catella · Mar 6, 2017 · Viewed 8.8k times · Source

I am getting this error

Not Acceptable

An appropriate representation of the requested resource /admin/prc_res.php could not be found on this server.

Additionally, a 406 Not Acceptable error was encountered while trying to use an ErrorDocument to handle the request.

There is a $_POST['additionalinfo'] (from html teaxtarea) which is giving me this error. If I remove this, code works fine.

But why I am getting 406 error?

My index1.php in unnat1ir.in/cdn/

<!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>

And 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>

All the above codes working fine on localhost

Answer

Kiryamwibo Yenusu picture Kiryamwibo Yenusu · Apr 28, 2018

it is because you are not escaping some html characters that are entered through a textarea field like quotes etc. Try the code below it works.

mysql_escape_string($_POST['additionalinfo']);