> -----Original Message-----
> From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, September 28, 2002 9:14 PM
> To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED]
> Subject: Re: [PHP] Htmlentities and Newlines?
>
> On Saturday 28 September 2002 08:59 pm, John W. Holmes wrote:
> > > -----Original Message-----
> > > From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> > > Sent: Saturday, September 28, 2002 9:00 PM
> > > To: [EMAIL PROTECTED]; 'Sascha Cunz';
[EMAIL PROTECTED]
> > > Subject: Re: [PHP] Htmlentities and Newlines?
> > >
> > > On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote:
> > > > > Short question: following your advice, what would the data
look
> >
> > like
> >
> > > > in
> > > >
> > > > > the
> > > > > db if I typed in:
> > > > >
> > > > > Hi Sascha.
> > > > > Next line is doubled.
> > > > >
> > > > > Double.
> > > > >
> > > > > How would that appear iun the db? In mine, it looks exactly
like I
> > > >
> > > > typed
> > > >
> > > > > it
> > > > > above (using 1 & 2 with magic_quotes=on).
> > > >
> > > > It depends on your viewer, I guess. It may appear as though it's
all
> >
> > on
> >
> > > > one line, but the new lines are there, regardless.
Htmlentities()
> > > > doesn't do anything to linebreaks...
> > > >
> > > > ---John Holmes...
> > >
> > > Hi John,
> > >
> > > Tried that
> > >
> > > Echo "<tr><td>" . nl2br(htmlentities($myrow['request'])) . and it
> >
> > appears
> >
> > > exactly as it is written (as part of the text request). Maybe if I
try
> > > again
> > > Monday with a fresh mind, I might discover what I'm doing wrong.
> >
> > ?? Umm..that's what should happen. It's not exact, mind you, it just
> > looks the same in the browser. Any < you had was converted to <,
but
> > you'd have to look at the source. A newline should now have a <br />
> > along with it... Is that not happening?
> >
> > ---John Holmes...
>
>
> Nope. In the db I see it as it's displayed on-screen without any <br>
etc.
> Strangely, before I attempted to use htmlentities, in the db, I'd see
text
> like:
>
> This line<br>is broken in two.<br><br>Before this line is a
double
> space.
>
> Now I see:
>
> This line
> is broken in two.
>
> Before this line is a double space.
>
> I just KNOW I'm messing up here -- but where???
>
> Andre
OK...I think you are confused. :)
That's what you should see in the database. You are seeing text,
newline, text, two newlines, and text. That's what should be in the
database.
Now, when you pull that out, and run nl2br() on it, it'll show up like
this, in the source of the html output:
This line<br />
Is broken in two<br />
<br />
Before this line is a double space.
Bottom line !!! :
Store the data exactly as the user typed it.
Display the data using nl2br(htmlentities($text)).
OK?
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php