What’s the best route for storing data in MySQL. With MySQL should I just use, TEXT as my field type?
As well when using mysql_real_escape_string() with return’ed values \r\n .
But should I be running the htmlentities() on it after that?
And then when I return data to the screen I should use, NL2BR()?
Just trying to figure out the best route here for storing this information.
Thank you for your help!
TEXTorTINYTEXTor anything similar should be fine for storing ASCII data from the user. If you don’t need a lot of space you may think aboutVARCHARi think that
mysql_real_escape_string()escapes characters that may compromise the security of an SQL query (single quote, double quote, etc.) but doesn’t do much more than that.htmlentities()converts reserved html characters like < and > into their html encoded equivalent, < and > respectively. These characters are not dangerous for SQL queries so you probably do not need to escape them unless you want to display the HTML tag entered by the user as text, and not let it be interpreted as HTML.NL2BR()is probably not necessary either.Most importantly, your decision on when to use each of these functions will depend on your end application. You may need / want some but not others ( though you should definitely use
mysql_real_escape_string())