title: Undo mysql_real_escape_string
body: <p>I have the following code at the top of every of my php pages:</p>
  
  <pre><code>&lt;?php
  
      function name_format($str)
      {
          return trim(mysql_real_escape_string(htmlspecialchars($str, ENT_QUOTES)));
      }
  ?&gt;
  
  foreach ($_POST as $key =&gt; $value) {
          if (!is_array($value))
          {
              $_POST[$key] = name_format($value);
          }
      } 
  </code></pre>
  
  <p>This was pretty useful until now. I experienced that if I want to display a text from a <code>&lt;textarea&gt;</code> before writing it into a database, then it shows "\r\n" instead of normal line breaks.
  Even if I try to do the following, it doesn't work:</p>
  
  <pre><code>$str = str_replace("\r\n", "&lt;br&gt;", $str);
  </code></pre>