Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: open

Message Too Old, No Replies

Storing text formatting

     

Mr_Cat

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

5+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month