Re: [PHP] entering in text data and losing the \n

From: Chris Shiflett (shiflett_at_php.net)
Date: 11/30/03


Date: Sat, 29 Nov 2003 22:17:07 -0800 (PST)
To: Randy Johnson <rjohnson@seasidepc.com>, php-general@lists.php.net


--- Randy Johnson <rjohnson@seasidepc.com> wrote:
> I have a form with a text area.
>
> When the user submits the data it is saved to a mysql database in a
> field of type text.
>
> When I extract the data from the database and display it in php it
> loses the line return and the data is all crammed together.

It doesn't lose it. In HTML, a newline isn't rendered as a newline by a
browser unless it is surrounded by pre tags. You probably want to use the
br tag instead. PHP has a function to help with this:

http://www.php.net/nl2br

Hope that helps.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
     Coming mid-2004
HTTP Developer's Handbook
     http://httphandbook.org/



Relevant Pages

  • Re: [PHP] Two Actions in a Form?
    ... > What I want to do is have one action in a form execute if the user ... The actions will point to PHP programs. ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)
  • Re: [PHP] Re: post an array into another site
    ... This is no different than with PHP or most any other open source project. ... submitting patches is probably the most common precursor to ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)
  • Re: [PHP] Installing PHP on HP
    ... how about an NT 4.0 Workstation? ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)
  • Re: [PHP] Include an encoder into PHP distribution?
    ... Doesn't it seem a bit ridiculous for the PHP ... If I had to choose a winner, personally, I wouldn't pick your choice ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)
  • Re: [PHP] Re: Export MySQL
    ... > phpmyadmin does a very nice job of dumping a mySQL database. ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)