No, the problem is that you're calling this function indescriminately, which is just as bad as magic_quotes_gpc.
Developers who think magic_quotes_gpc is a good idea, fail to grasp the concept that a value may be used for something other than putting it in a database.
Here are some cases where values must not be escaped in this manner:
- Storage in a file on disc
- Storage in the session
- Putting in an email body
- Putting in a RPC request to a foreign server
- Passing through in a hidden (or non-hidden) field on the same or another page
- Doing any logic on the string value, for example, comparison to some value fetched from a database.
These are just a small set of possibilities where adding slashes is going to cause corruption, and in each case where one of these things is done, care must be taken NOT to add slashes, otherwise you'll end up with the dreaded "backslashitis"
The trick is, to escape values AS THEY GO INTO THE DATABASE, not at any other time. If you escape values anywhere else, then they could accidentally be used for some other, non-database purpose, which will result in corruption.
As I mentioned before, prepared statements are DEFINITELY the right way to go.
Mark