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!

Perplexing Paragraph Parsing 1

Status
Not open for further replies.

Zilch

Programmer
Nov 24, 2003
10
0
0
US
Okay, I'm trying to write a pm system for my site. However, as far as I know (a friend of mine ran into this problem) MySQL databases don't store paragraphs.

I'm wondering if maybe ASCII is stored (if so, the ASCII code is 12), or how I could fix this problem. Then I need to parse the output, so it looks right. (Such as replacing ASCII-12('n(ew)p(aragraph)') with \n\n<p>)
 
Your friend has you ill advised.
MySQL databases store whatever is put into them. The problem you are encountering has to do with the way HTML interpets whitespace. Newline characters are not interpreted as breaks in HTML. They are there, stored, retrieved and all. HTML however requires <br /> or <p></p> tags to delineate paragraphs.

PHP has the handy function nl2br() which translates any newline character in the given string into a <br /> tag.

MySQL is not the culprit. It is an inherent HTML issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top