RE: [PHP-DB] Handling Linefeeds in MySQL/PHP

From: Date: Wed, 04 Jul 2001 08:47:56 +0000
Subject: RE: [PHP-DB] Handling Linefeeds in MySQL/PHP
Groups: php.db 
Request: Send a blank email to php-db+get-10057@lists.php.net to get a copy of this message
you could also use nl2br() nl2br (PHP 3, PHP 4 ) nl2br -- Inserts HTML line breaks before all newlines in a string Description string nl2br (string string) Returns string with '<br />' inserted before all newlines -- no point reinventing the wheel .... Steve > -----Original Message----- > From: Micah Stevens [mailto:micah@digitaloblivion.com] > Sent: 03 July 2001 22:06 > To: php-db@lists.php.net > Subject: Re: [PHP-DB] Handling Linefeeds in MySQL/PHP > > > The information returned from a text box includes line feeds > in the form of > "\n" which is not recognized by browsers as a line feed. To > make it display > properly, you need to convert all the "\n"s to "<br>"s.. > Here's a snippet > of code that I use: > > // Assume that the text field is named 'message' and this is > the code that > processes the form input > $message = ereg_replace("\n","<br>", $message); > //Now this will display properly. > > Often it is handy to change quotes to &quot so that you don't > run into php > conflicts when you're processing the text. You can use the > same command to > do that. > > Hope this helps, > -Micah Stevens > Raincross Technologies > > > > > > > At 02:29 PM 7/3/2001 -0500, you wrote: > >I am creating a content management page that uses a textarea > box to enter a > >chunk of text which then is sent into the database into a > text-type field. > > > >I am finding that when the data is retrieved to be shown in > the browser that > >the line feeds are lost. I don't want users to have to know > HTML to put > >tags in themselves. What's the best way to handle this? > > > >Can I read from the database and insert br's and p's to be > put into the > >displayed HTML? Or, instead, is there a way to put the br's and p's > >immediately into the database when the record is inserted? > How can I do > >this? How would the string be manipulated? > > > >Thanks for your help, > >-Casey > > > >-- > >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 > > > -- > 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 >

« previous php.db (#10057) next »