Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Storing text formatting

1:21 pm on Feb 12, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Sept 15, 2008
posts: 90
votes: 0

Hi folks,

I was struggling with storing and reproducing text formatting for a while there, more just the reperpoducing it again when echo'd to the screen.

I was putting;

This is
a line break

Into a text box, stashing it in the db, then when looked at in phpMyAdmin it read

This is
a line break

in the table view. I was alarmed I might be stashing lots of white space but someone then told me that phpMyAdmin was just being 'nice' and reformatting it for me which was quite annoying because it took me a while to figure out I needed 'nl2br' as I couldn't see any \n's in the database text. This now sorted tho, I noticed that with some forum software I use, their posts table contains all the posted messages with html inserted, they read like an html page when viewed in phpMyAdmin.

So, is there any particular considered good and bad practices as to how to store your text formatting, put html into the db, or just convert it by other means when you retrieve it, or is it merely a matter of taste?

The same friend told me he considered it better not to stash html in my tables, but didn't give any particular reason.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members