Hi,
I need to write a PHP function to escape characters for an SQL statement. I think the characters I need to lookout for are:
single quote '
double quote "
backslash \
I know I can use something found on the net, I just want to give this a try first. I'm using a simple string replace method, but am getting confused on what to replace the found characters with. For example:
Single Quote, Find ("\'") Replace with ("\\'");
Double Quote, Find ("\"") Replace with ("\\\"");
Backslash, Find("\\") Replace with ("\\\\");
That works when I print them to screen - but I"m confused if the replace with strings I posted are the proper things for use with an actual SQL statement.
Thanks
Start Free Trial