I have a table like this...
select * from myescape;
+-----------+
| name |
+-----------+
| shantanu' |
| kumar's |
+-----------+
2 rows in set (0.00 sec)
I need to replace the single quote ' with \'
I will also need to escape double quotes and backslash.
The point of prepared statements is that you don't have to include content in them. Use a PREPARE
query with ?
placeholders and then EXECUTE ... USING
to pass the values in without having to escape them.
Don't try to do escaping yourself, because you're likely to make mistakes. Depending on what encoding you're using, there can be more to it than just backslash-escaping quotes, backslash and null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With