views:

19

answers:

2

Newbie question here.

I have a web form with a text area and naturally users will enter newline characters also. I am storing this form to a table in the DB. I also have to create a report from this. So I dump the table to text and am trying to parse it. The delimiters for me between multiple records is a new line character. But the new line character in the text area is throwing my script off.

I am sure someone must have run into this before. Can you suggest me ideas as to how to deal with this? I tried having the text from the text area in double quotes but that will complicate my parsing logic. I was wondering if there is an easier way to deal with this.

Thanks, Pav

+1  A: 

I think the simple answer is some form of escaping.

You could do some find/replace in the SQL, such as REPLACE(thetext, '\n', '\\n'), or if the newlines are not important, you could do REPLACE(thetext, '\n', ' ')

orangeoctopus
+1  A: 

Recently ran into the same issue. Your best best is to replace the newline characters during the data dump (or before the data gets to your database) with something else. I opted for something like // or <br> so that I can recover the new lines later.

Mark E