title: keep textarea input format after using mysql_real_escape_string to store
body: <p>I am using php5.3.6 and mysql 5.1.56 and CodeIgniter. Here is what I did.</p>
  
  <ol>
  <li><p>Input some text in textarea, something like this:</p>
  
  <hr>
  
  <p>what's this?</p>
  
  <p>I'm bob.</p>
  
  <hr></li>
  <li><p>$string = $_POST['name'];</p></li>
  <li><p>$insertdata = mysql_real_escape_string($string);</p></li>
  <li><p>Insert $insertdata into database.
  It shows "what\'s this?\n\n\nI\'m bob."(without double quotes) in the table.</p></li>
  <li><p>Query the data stored in database, use stripslashes on it and then put it back to the textarea.
  It shows "what's this?nnnI'm bob."(without double quotes) in the textarea.</p></li>
  </ol>
  
  <p>My questions are:</p>
  
  <ul>
  <li>In step 4, shouldn't it be "what\'s this?\n\n\n   I\'m bob." stored in the table?
  I checked php manual. It says:</li>
  </ul>
  
  <blockquote>
    <p>mysql_real_escape_string() calls
    MySQL's library function
    mysql_real_escape_string, which
    prepends backslashes to the following
    characters: \x00, \n, \r, \, ', " and
    \x1a.</p>
  </blockquote>
  
  <ul>
  <li><p>How am I supposed to keep the textarea input format after using mysql_real_escape_string()?</p></li>
  <li><p>Is there anyway to choose which slash to strip and which not to?</p></li>
  </ul>
  
  <p>Notes:</p>
  
  <ul>
  <li>magic quotes option is off</li>
  <li>I did not use stripslashes() before
  using mysql_real_escape_string()</li>
  <li>If I use addslashes() instead of
  mysql_real_escape_string(),
  everything works fine.</li>
  <li>I don' want to use addslashes() since
  it is not as secure as
  mysql_real_escape_string(), as far as
  I know.</li>
  </ul>
  
  <p>Thanks,
  Milo</p>