# MySQL and new lines

**URL:** <https://www.ruby-forum.com/t/mysql-and-new-lines/129382>\
**Category:** Ruby\
**Created:** [February 18, 2008, 1:59am UTC](https://www.ruby-forum.com/t/mysql-and-new-lines/129382 "2008-02-18T01:59:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![larios](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc79bd/32.png) [@larios](https://www.ruby-forum.com/u/larios)\
**Post date:** [February 18, 2008, 1:59am UTC](https://www.ruby-forum.com/t/mysql-and-new-lines/129382/1 "2008-02-18T01:59:27Z")

</div>

Hi,

So I was having trouble earlier with getting MySQL to accept single  
quotes from a textarea, but I got that resolved using both the MySQL  
escape\_string and the CGI escape method (I finally settled on the  
escape\_string), and that’s taken care of that problem.

However, I can’t seem to figure out how to keep newlines that are  
inserted by users? I’ve looked around on Google and can’t seem to find  
any answers. I’ve tried gsub to replace the \n with a \n  
 (I saw  
that method employed with PHP’s str\_replace, but no luck here).

Any other suggestions or solutions?

Thanks a lot,  
Mark
