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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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



Feb 23, 2004, 3:07 AM

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


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?

Thaumaturge / Moderator

Feb 24, 2004, 12:02 AM

Post #2 of 3 (1042 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.

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

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Feb 24, 2004, 2:47 AM

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


I've seen

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

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



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

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