I wrote a script that lets people login and edit their profiles which are stored in a MySQL database.
One of the fields is Quote...and I've noticed a very annoying problem. When people go to do...
"My Quote"
...and then click submit, it doesn't get updated, since MySQL rejects it. The users have to put a \ to escape the " first. Now that is a very easy solution in itself, but lets face it, that's annoying. Very, VERY annoying.
I remember in CGI you could transform characters in variables by doing this:
$var =~ tr/a/b/;
That would change all the letter a's in the variable to letter b's, basically. I tried that in PHP, and it didn't work.
I want to change all ' and " to \' and \" without making the users do it. Is this possible with PHP? If so, how?
One of the fields is Quote...and I've noticed a very annoying problem. When people go to do...
"My Quote"
...and then click submit, it doesn't get updated, since MySQL rejects it. The users have to put a \ to escape the " first. Now that is a very easy solution in itself, but lets face it, that's annoying. Very, VERY annoying.
I remember in CGI you could transform characters in variables by doing this:
$var =~ tr/a/b/;
That would change all the letter a's in the variable to letter b's, basically. I tried that in PHP, and it didn't work.
I want to change all ' and " to \' and \" without making the users do it. Is this possible with PHP? If so, how?