When you have a problem such as this. It's best to reduce or limit the
possible problems that could be causing it.

It looks as though you want to basically format your database content to
preserve new lines and the like.

If I were you I'd start by just using nl2br(), then when you use
htmlspecialchars() it has a similar function when it comes across new
lines. (as well as reformatting HTML entities)

Check also whether you need to use addslashes() as PHP4.2.1 has magic
quotes turned off: magic_quotes_gpc off (Check your phpinfo.php file or
write one yourself.)

Good luck - and you really don't wanna know what "RTFM" means but you
could find out at:


-----Original Message-----
From: José Moreira [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 11:19 PM
To: 'Martin Clifford'; Php-Db (Correio electrónico)
Subject: RE: [PHP-DB] TEXTAREA ...

good day/afternoon/night

why do i get this :

  $content = htmlentities($content);<br />

when i insert this :

        $content = htmlentities($content);[new line]

using this :

        $thePost =

when i want this :

          $content = htmlentities($content);<br>

and i sometimes get

<br /><br />

once again sorry for asking non-db questions

good work

-----Mensagem original-----
De: Martin Clifford [mailto:[EMAIL PROTECTED]]
Enviada: quarta-feira, 17 de Julho de 2002 15:02
Assunto: Re: [PHP-DB] TEXTAREA ...

Yup.  So:

$content = nl2br(htmlentities(stripslashes($content)));
// Good for echo'ing HTML into the page

$content = nl2br($content);
// Good for showing $content with HTML formatting

Martin Clifford
Developer's Forums:

>>> "Martin Adler" <[EMAIL PROTECTED]> 07/17/02 09:48AM >>>
That's right but if the variable is initialised by the form and you want
write the variable in to your html-document it's better to write this

$content = nl2br(htmlentities(stripslashes($content)));

----- Original Message -----
From: "Martin Clifford" <[EMAIL PROTECTED]>
Sent: Wednesday, July 17, 2002 3:15 PM
Subject: Re: [PHP-DB] TEXTAREA ...

$content = nl2br($content);

That will convert all newline characters into <br> tags.


Martin Clifford
Developer's Forums:

>>> José Moreira <[EMAIL PROTECTED]> 07/17/02 09:15AM >>>
hello ... im sorry to bother with a non-db question but i searched for
and got 0 record :P

its all about the wrappig in textareas:

how can i convert the end of line/ line breaks ['enter' keys] that the
hits while
filling a textarea so that when i display the record content the text
break where the user intended ???


<textarea>bla blah blah
                 bla blah blah</textarea>

if i echo() this textarea value i will apear in a single line even if
user pressed enter 2  break the line

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to