RE: [PHP] Forms and viewing Text Area

2004-12-10 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 09 December 2004 22:41, Ben C wrote:

 I have a form which has a text box which then stores in MySQL.  When I
 write seperate paragraphs and try and then view what I wrote it lumps
 it all together in one paragraph when I echo.  I am sure I am doing
 something simply wrong.  Anyone have any ideas?

echo nl2br(htmlspecialchars($text)) is my usual mantra for this.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Forms and viewing Text Area

2004-12-10 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 echo nl2br(htmlspecialchars($text)) is my usual
 mantra for this.
 
nl2br will give you back the correct formatting, but
will leave br/'s in the output.

I just went through this issue the other day, what I
found worked for me was:

htmlspecialchars('string'),ENT_NOQUOTES);
Note- check the available parameters for
htmlspecialchars. I used ENT_NOQUOTES because I wanted
to preserve the single and double quotes in my text.

Hope this helps.

Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Forms and viewing Text Area

2004-12-10 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 10 December 2004 11:30, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  echo nl2br(htmlspecialchars($text)) is my usual
  mantra for this.
  
 nl2br will give you back the correct formatting, but
 will leave br/'s in the output.

OK, yes, a case of engage brain before operating keyboard: in a textarea,
that may be the case; if you're just sending it out as part of straight
HTML, my mantra is right!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Forms and viewing Text Area

2004-12-09 Thread Marek Kilimajer
Ben C wrote:
I have a form which has a text box which then stores in MySQL.  When I
write seperate paragraphs and try and then view what I wrote it lumps
it all together in one paragraph when I echo.  I am sure I am doing
something simply wrong.  Anyone have any ideas?
put pre tag around it. and don't forget htmlspecialchars():
echo 'pre' . htmlspecialchars($input) . '/pre';
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Forms and viewing Text Area

2004-12-09 Thread John Holmes
Ben C wrote:
I have a form which has a text box which then stores in MySQL.  When I
write seperate paragraphs and try and then view what I wrote it lumps
it all together in one paragraph when I echo.  I am sure I am doing
something simply wrong.  Anyone have any ideas?
The line breaks are preserved. If you look at the HTML source of your 
page, you'll see that. HTML does not render line breaks, though, you 
need br / tags. So using nl2br() or something similar would work.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php