Cleaning Up and Storing Text Area Contents
Posted: Tue Oct 07, 2008 9:23 am
I have a medium sized text area that takes user input. Somewhere between one and 5 paragraphs.
What functions should I run on the incoming text to clean it for database storage?
mysql_real_escape_string(), of course, but that doesn't detect and convert non-standard characters, does it?
Specifically:
*When the user pastes content from MS Word, you get 'quotes' that aren't actually quotes and all sorts of other strange characters.
*If the user inserts line breaks, should I convert them to HTML? Should I use HTML_special_chars()? Will that be enough?
*I'm thinking that I do want to allow HTML markup, for formating purposes.
On one of the Zen Cart powered sites I maintain, there's all sorts of strange things in the "product descriptions" field that cause the Google Base feed to choke. Most of this is from 'Word pasting'. I'd like to avoid any non-standard character weirdness this time around.... Any ideas?
And on the database end, do you use BLOB or Text?
What functions should I run on the incoming text to clean it for database storage?
mysql_real_escape_string(), of course, but that doesn't detect and convert non-standard characters, does it?
Specifically:
*When the user pastes content from MS Word, you get 'quotes' that aren't actually quotes and all sorts of other strange characters.
*If the user inserts line breaks, should I convert them to HTML? Should I use HTML_special_chars()? Will that be enough?
*I'm thinking that I do want to allow HTML markup, for formating purposes.
On one of the Zen Cart powered sites I maintain, there's all sorts of strange things in the "product descriptions" field that cause the Google Base feed to choke. Most of this is from 'Word pasting'. I'd like to avoid any non-standard character weirdness this time around.... Any ideas?
And on the database end, do you use BLOB or Text?