RE: [PHP] Htmlentities and Newlines?

From: Date: Sun, 29 Sep 2002 01:13:21 +0000
Subject: RE: [PHP] Htmlentities and Newlines?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118020@lists.php.net to get a copy of this message
> -----Original Message----- > From: Andre Dubuc [mailto:aajdubuc@webhart.net] > Sent: Saturday, September 28, 2002 9:14 PM > To: holmes072000@charter.net; 'Sascha Cunz'; php-general@lists.php.net > Subject: Re: [PHP] Htmlentities and Newlines? > > On Saturday 28 September 2002 08:59 pm, John W. Holmes wrote: > > > -----Original Message----- > > > From: Andre Dubuc [mailto:aajdubuc@webhart.net] > > > Sent: Saturday, September 28, 2002 9:00 PM > > > To: holmes072000@charter.net; 'Sascha Cunz'; php-general@lists.php.net > > > 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 &lt;, 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...

« previous php.general (#118020) next »