Forum Moderators: open

Message Too Old, No Replies

Storing HTML Breaks vs \n Line Breaks

         

HoboTraveler

7:14 pm on Aug 30, 2006 (gmt 0)

10+ Year Member



Hi All,

When storing a paragraph of text in a MySQL DB, I follow either of the two methods:

- Store the text with \n line breaks and convert the line breaks to html breaks using nl2br when the data is being displayed

- Store the text with html breaks during insert.

I was wondering if there are advantages in storing text as it is. That is, \n line breaks. Is there a performance decrease in converting line breaks to html breaks during execution? Am using PHP..

TIA

physics

8:02 pm on Aug 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are advantages/disadvantages to each method I guess:


- Store the text with \n line breaks and convert the line breaks to html breaks using nl2br when the data is being displayed

Saves hard drive space. There will be a performance hit when converting \n to <br />, whether or not this is a problem depends on how much traffic there is on your site.


- Store the text with html breaks during insert.

Takes a bit more space. For long text with few line breaks probably not a big deal but if you have a lot of line breaks it could be signifigant. Will be faster to display since don't have to convert chars.