CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
MySQL: Chaning $indata with <BR>'s.

 



andy7t
User

Feb 23, 2004, 3:07 AM

Post #1 of 3 (479 views)
MySQL: Chaning $indata with <BR>'s. Can't Post

Hello,


I have a textarea (box) like the one i'm typing in now.

When i press submit, it sends everything to my script.

The textarea box is $indata{'message'}.

Now, i sned this email to myself- and all of the Linebreaks are included- which is fine.

It is also stored in a mysql database, under a LONGTEXT field.

Now, when i go back to my other script, and print that field on the screen there are no line breaks.

How do i get it to put in <BR>'s at every line break or something?


davorg
Thaumaturge / Moderator

Feb 24, 2004, 12:02 AM

Post #2 of 3 (477 views)
Re: [andy7t] MySQL: Chaning $indata with <BR>'s. [In reply to] Can't Post

If you look at the source code of the page that is created then you'll see that there _are_ line breaks in the source code but, of course, white space (including line breaks) is ignored when a browser renders HTML.

You have two options:

1/ Force the browser to honour the line breaks by putting the data within <pre> tags.

2/ Change the line breaks to something that will be displayed as a new line by the browser - like a <br> tag. You can use the substitution operator like this.

Code
$text =~ s/\n/<br>/g;


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


andy7t
User

Feb 24, 2004, 2:47 AM

Post #3 of 3 (476 views)
Re: [davorg] MySQL: Chaning $indata with <BR>'s. [In reply to] Can't Post

Thanks!

I've seen

$text =~ s/\n/<br>/g;

Something like that before- i just couldn't find it again!!

Thanks


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives