Hello
I hope you can give me some advice please.
Until recently, we stored all MySQL input with mysql_real_escape_string(htmlentities(foo)), until someone said to me that was the wrong way, as I should be formatting it when extracting it from the database, not before.
I have therefore been through all my PHP (thousands of lines!, taken hours) and removed them so now they just have mysql_real_escape_string().
I then went through our SQL dump and replaced the 5 things that htmlentities() replaces.
Anyway, where I'm at now is wondering when to use htmlentities()? So far, I've just done it when we allow a textarea input that we echo our with nl2br.
However, before adding htmlentities() to everywhere we echo out data, is there some custom SQL function I can use to let PHP do it itself? We have literally thousands of things we echo out, and adding htmlentities() to each (which comes from user input) will be a nightmare.
Any advice/code/help would be greatly appreciated. :o