A while back (perhaps a month or so), I tested the PHP functions addslashes() and removeslashes() and found that the add side worked quite well, but the remove side did not work. Any field I had that required slashes got an increasing number of slashes each time I stored it. So I called my hosting service to see if I even needed to use these functions. What I was told at the time is that they have a setting that eliminates the need to use these functions, that they automatically take care of the problem.
So I stripped out all the hundreds of lines of code that implemented slashes throughout my site.
Now I am testing the site on real data, and I find that I have a problem with any fields that contain a single quote or an apostrophe (same character). Specifically, MYSQL sees the single quote embedded within a field as the end of that field (since I enclose all fields in single quotes when I build the INSERT SQL string. As a result, I get an SQL error when I try to execute the INSERT command.
I am at a bit of a loss as to what to do. The books say use the PHP functions addslashes() and removeslashes(), but when I did that, I had problems. When I do not use them, I also have problems. I cannot use double quotes instead of single quotes. That would have the same problem when the string contained a double quote, and PHP would not be able to resolve the field names because it would assume that the variable name was a literal string instead of a variable name.
Any suggestions? I know I am not the first person to have this problem.
Thanks,
Mel