Today, I wanted to strip slashes from a comment field using SQL (INSTEAD of using php stripslashes).
Why you ask?
I was working on an application which had not considered stripslashes for formatting output.
So I had a look and realised. Do I change 40,000 lines of code to add Stripslashes, or 1 line at the SQL select statement?
OK, slight exaggeration, but you get what I mean.
Select Replace(field_name, '\', '') as stripped_field from table;
Select Replace(field_name, '', '') as stripped_field from table;
If using in PHP add an extra backslash like this;
// strip slashes as part of the SQL select statement $sql = "Select Replace(field_name, '\', '') as stripped_field from table";
Please get in touch if you know of an easier way to do this, for example, Oracle Functions, or MySQL functions.
Many thanks and happy coding.