Reputation: 33
i have a form that submits data to a database, i have a function that looks like this:
//connect
foreach ($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
now when i post, SOMETIMES i get an error that says this:
Allowed memory size of 268435456 bytes exhausted
i figured out that when i do a linebreak, or press enter in the message field, then that is when it causes the error, otherwise it works normal. any ideas?
Upvotes: 3
Views: 473
Reputation: 96159
Please try to reproduce the error with
$mysql = mysql_connect(...
printf("<pre>Debug: count(_POST)==%d</pre>", count($_POST));
foreach ($_POST as $key => &$value) {
printf("<pre>Debug: strlen(_POST[%s])==%d</pre>", htmlspecialchars($key), strlen($value)); flush();
$value = mysql_real_escape_string($value, $mysql);
}
printf("<pre>Debug: Done.</pre>");
Does this print something "unusual" before the "Allowed memory size of 268435456 bytes exhausted" message?
edit and btw: I don't "like" the way you're trying to handle the real_escape_string thingy for two reasons:
Upvotes: 1