Hello Will,

On 28 Jan 2004 at 12:31, Will wrote:

> 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. 

Just adding to Marek's response in an attempt to make things clearer for you.

I think what's bothering you is the fact that you don't see the backslashes added by 
addslashes in the strings stored in the database. Well, that's because they are *not* 
actually added to the strings; they simply tell the database to treat whatever 
character 
comes after them (them = the backslashes) as regular text, not as symbols with special 
meanings (such as quotes, which MySQL would normally sees as string delimiters, not 
actual quotes in a string of text).

Since no backslashes have actually been added to the strings stored in the database, 
you don't need to (or, rather, should not) use stripslashes when retrieving the 
strings 
from the db.

By the way, consider using mysql_escape_string or mysql_real_escape_string instead 
of addslashes; consult the PHP manual for more info on these functions.

Cheers,

Erik

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to