How should I go about adding slashes to only single quotes and ignoring double quotes? I am using php. I would only like to escape single quotes to prevent my php mysql queries from breaking.
Thank you!
Edit: I am thinking a regular expression search and replace will be the most helpful.
Okay am really late to this post but adding this answer hoping that it might help someone landing at this question. While @Weston C has given a regex solution, there is a php function for doing this- addcslashes (http://php.net/manual/en/function.addcslashes.php):
string addcslashes ( string $str , string $charlist )
Returns a string with backslashes before characters that are listed in charlist parameter.
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