|
Posted by Richard Lynch on 02/02/05 00:58
Brian Dunning wrote:
> I am storing some text from forms into MySQL as base64_encode(). So far
> this has worked well at dealing with weird characters. But when I
> output it, everything is escaped with \. I can't replace those out with
> '' since sometimes they are supposed to be in there. What's the best
> way to output this text from the database and not have the \ visible?
The problem is, almost for sure, that your data had
http://php.net/addslashes called on it, possibly because "magic quotes
gpc" was turned on.
So when you then base64_encode() it, the extra slashes that are there for
MySQL to "know" what is data rather than syntax are *ALSO* turned into
data in your base64-encoded content.
Your choices are:
Fix the original source code that called *both* addslashes (directory or
indirectly through magic quotes)
Or, be stuck with bogus data and always have to remember to call
http://php.net/stripslashes on it after you base64_decode() it.
The first solution is preferrable, but you'll need to:
Record the record number where the data is currently bogus.
Fix the source to NOT call addslashes + base64_encode
Copy out all the bogus records.
Call base64_decode/strip_slashes/base64_encode and store that result back in
In the short-sighted view, it looks easier to just do the second solution
-- but every time you come back to this data, you'll curse yourself for
that...
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|