Re: String variable read from Mysql DB + echo = Newline problem
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Mon, 20 Mar 2006 06:51:12 -0500
weirdstuff wrote:
Errr, what? :)
Ok I had figured that a backslash was being added when I read the
string from DB, but all my attempts of correcting that have failed.
What we have here is a case where knowing how the output is formatted
_exactly_ is very important. So it would be nice to be able to
"manually" format stuff like newlines and breaks.
Now, your suggestions:
So, what you have to do is change your formatting characters. Replace
"\\n" with "\n" and "\\r" with "\r", for instance.
The string already has single backslash in the database. If I add
another "just for fun" I just get two in the output. If I then do a
stripslashes() on one or the other then that doesn't help either.
Or, alternatively, put the actual characters themselves in the database.
Thats exactly what I'm trying not to do.
So we can agree that the problem is when I am getting the string from
the database. Then PHP (or MySQL?) does some funkyness to the string
variable which makes PHP think that \n means it should print
"backslash" and "en"
Jolly good show. Now lets fix it! :)
Please read it again. Replacing "\\n" with "\n" will not add another backslash. It will convert the backslash and en to a newline character.
You really only have two choices. Either put the characters themselves in the database, or put something representing the characters in the database and substitute after you read them out.
And BTW - you cannot exactly control formatting on the user's browser. All you can do is recommend formatting. If you want exact, create a PDF.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: String variable read from Mysql DB + echo = Newline problem
- From: weirdstuff
- Re: String variable read from Mysql DB + echo = Newline problem
- References:
- String variable read from Mysql DB + echo = Newline problem
- From: weirdstuff
- Re: String variable read from Mysql DB + echo = Newline problem
- From: Jerry Stuckle
- Re: String variable read from Mysql DB + echo = Newline problem
- From: weirdstuff
- String variable read from Mysql DB + echo = Newline problem
- Prev by Date: php oop for dummies
- Next by Date: Re: Query SQLServer
- Previous by thread: Re: String variable read from Mysql DB + echo = Newline problem
- Next by thread: Re: String variable read from Mysql DB + echo = Newline problem
- Index(es):
Relevant Pages
|