Re: Re: Processing newlines in a text area field
| From: | David Robley | Date: | Fri, 14 Oct 2011 23:29:24 +0000 |
| Subject: | Re: Re: Processing newlines in a text area field | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315305@lists.php.net to get a copy of this message | ||
On Fri, 14 Oct 2011, you wrote:
> On 11-10-14 03:40 AM, David Robley wrote:
> >> I have a web page with a form with a text area. I enter:
> >>
> >> foo
> >>
> >>
> >> bar
> >>
> >> PHP processes the POST and inserts the record into MySQL.
> >>
> >> The database field is text.
> >>
> >> I use PDO
> >>
> >> For testing I have removed any processing of the text area content.
> >>
> >> Now, no matter how many blank rows I have between foo and bar, in
> >> the database record, I always get a single newline character.
> >>
> >> I am using Firefox 7.0.1.
> >>
> >> Is this normal behaviour? I want to be able to enter more than 1
> >> newline.
> >
> > You may have forgotten that HTML treats all whitespace, such as tabs,
> > newlines and spaces, as a space, unless you wrap the text in PRE
> > tags.
> >
> > To display a line break where your text contains EOL characters, use
> > nl2br()
>
> I am using nl2br() and i get just 1 <br /> added. So I went back to the
> database and found only a single newline.
>
> So either MySQL or PDO seems to be getting rid of "excessive" white
> space.
>
> Still no solution.
>
> Stephen
Please keep replies on list so others can help.
I suggest you provide the particular code that is causing the problem,
perhaps with a sample string that will trigger the problem.
Cheers
--
David Robley
Shh! Be vewy quiet, I'm hunting wuntime errors!
Today is Pungenday, the 69th day of Bureaucracy in the YOLD 3177.