addslashes & stripslashes
| From: | Will | Date: | Wed, 28 Jan 2004 12:31:25 +0000 |
| Subject: | addslashes & stripslashes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176031@lists.php.net to get a copy of this message | ||
I'm a little confused with these functions. How I here you ask. Well I
thought I understood what they were for:
Escaping characters that might cause a problem when you enter your data
into a database query. i.e. \ ' "
Anyway what is confusing me is, say I have a string which contains an '
e.g: that's mine. I would use addslashes so that the query wouldn't
upset mysql when it is entered. Viewing the data entry via phpmyadmin
the data is displayed as: that's mine (not: that\'s mine) Meaning that
when I extract the data from the database I need to use stripslashes
returning the string to: that's mine. (I thought that perhaps phpmyadmin
striped the slashes when displaying the data.)
However recently I encrypted some data which I stored in the database.
The string contained a \ which I added slashes to when entered in to the
database. But as the database appears to strips the first slash off the
double slash automatically. Upon retrieving the data and strip the
slashes off it, my data is now corrupt as there weren't double slashes
it was just a single (like it was supposed to be) and that got removed
by the function instead of the extra one.
As I haven't had any data that contains a \ in it before I've never
noticed it's not made any difference before.
So Does this basically mean that there is no point using stripslashes on
the data you extract from the database.
Or am I just being an idiot :-)
Thanks
Will
_____
I've stopped 46,346 spam messages. You can too!
One month FREE spam protection at www.cloudmark.com
<http://www.cloudmark.com/spamnet?v1>
<http://www.cloudmark.com/spamnet?v1>
Cloudmark SpamNet - Join the
fight against spam!