Re: HTML tags destory formatting?

From: Date: Mon, 23 Jul 2001 12:29:08 +0000
Subject: Re: HTML tags destory formatting?
Groups: php.db 
Request: Send a blank email to php-db+get-10662@lists.php.net to get a copy of this message
Thanks for the response, but that is exaclty what I am doing. Here's an example: I input the following into a varchar field: This is the first line of text. This is the second line of text. This is some text with a <a href="link.php">link</a> This is the next line. This is the last line. On inserting into the database I tell it to do a nl2br() prior to the insert. The output from a print() statement is: This is the first line of text. This is the second line of text. This is some text with a <a href="link.php">link</a> This is the next line. This is the last line. You see that the formatting is lost after the <a href..> tag. Any suggestions? Geoffrey sandis@mediaparks.lv wrote: > >There are two cases possible: >1. Store already HTML-formatted text in db. Then you do nothing > before sending it to the screen; never use nl2br() here! >2. Store plain text, may be with a simpliest tags like b, i, u, > ol, ul, li, a, img. Then put it through the nl2br() function > before outputting to browser. > It's easy for the editor that will update news on the site. So she > can, for example, copy text from Word document into the form's > <textarea> in natural paragraphs, & in browser it will look the > same, without need to insert <br> or <p> for paragraph formatting. >Just select which one is more suitable for u. >Monday, July 23, 2001, 2:37:15 PM, Geoffrey Makstutis <gmak@51pct.com> wrote: >GM> Hi, >GM> I'm getting a problem when I pull text from a mySQL database. The text is froma >GM> varchar field and contains some HTML tags. New lines are translated to <BR>, but >GM> when the field is outputted, anything coming after an HTML tag loses its formatting >GM> (ie. no line breaks converted to <BR>). >GM> Can anyone suggest a solution? >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net >For additional commands, e-mail: php-db-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ----- Geoffrey Makstutis <gmak@51pct.com> 51% Studios Architecture + Design 1-5 Clerkenwell Road London EC1M 5PA www.51pct.com

« previous php.db (#10662) next »