Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling line feeds

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
What is the correct way to handle line feeds when storing multi line text paragraphs in MySQL?
The returns just seem to just disappear and leave me with a sinle line of text.
I would ask in the MySQL forum but they just tell me to use PHP.

I could go for HTML substitution but there must be a simple solution.

Keith
 
i think it will store \n 's with no problem. Your not chomping the data before you insert it are you?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I just inserted some into a varchar field and a text field (which I think in mysql is same as a unlimited length varchar field).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I am not chomping the data but I am being a bit numb, it's been a long day.
I am inserting the data into a HTML template and expecting form feeds to morph into line breaks.

In case anyone views this thread looking for a solution, the line feeds need substituting for HTML breaks.
Code:
$RawLine=~ s/\n/<br>/g;

Keith
 
you can always put pre tags around it to.. but sometimes they look funny.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top