title: How should i store newlines in a MySQL database?
body: <p>I'm going around and around in circles in my mind trying to decide how best I should store newlines in a MySQL database.</p>
  
  <p>A bit of background; the user is asked to complete a textarea. This has to stored in a MySQL database before being read back out and the content included in an HTML email.</p>
  
  <p>Should I store them as:</p>
  
  <p>1) String literal - surely this is dangerous and bad practice</p>
  
  <p>2) As a string with <code>\r\n</code> in - when I read this back out of the database its read as 4 characters so <code>nl2br()</code> fails to correctly replace them.</p>
  
  <p>3) As HTML <code>&lt;br /&gt;</code> - as it has to be html entity encoded to be stored it ends up being stored as <code>&amp;lt;br /&amp;gt;</code> so when it gets to the email <code>&lt;br /&gt;</code> is printed rather than an actual newline. Passing it through <code>html_entity_decode()</code> would decode other characters that need to be encoded.</p>
  
  <p>Any help  grately appreciated.</p>