Is the memory size exceeded?

I have a form that passes data to the 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 send a message, SOMETIMES I get an error message:

Allowed memory size 268435456 bytes exhausted

I realized that when I do a line break or press Enter in the message field, then this happens when it causes an error, otherwise it works fine. any ideas?

+3
source share
1 answer

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>");

Is something "unusual" printed before the message "Allowed memory of 268435456 bytes in size"?

edit btw: "", real_escape_string :

  • _POST, . ( magic_quotes, ;-))
  • , , , . " , _POST", - . , , . , , , ​​ [ , / , ]
+1

Source: https://habr.com/ru/post/1736840/


All Articles