Home > Archive > PERL Miscellaneous > April 2005 > '\n' & <br> problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
'\n' & <br> problem
|
|
|
| if( param('select') ) {
$data = open_script( $host, param('select') );
} elsif( $match ) {
$data = welcome_old( $host );
} else {
$data = welcome_new( $host );
}
sub welcome_old {
my ($host) = @_;
$dbh->do( "UPDATE guestlog SET hostcount = hostcount + 1 WHERE
host='$host'" );
my $sth = $dbh->prepare( "SELECT * FROM guestlog WHERE
host='$host'" );
$sth->execute();
my $row = $sth->fetchrow_hashref;
return "Êáëþò Þëèåò " .$host. "! ×áßñïìáé ðïõ âñßóêåéò ôç_
óåëßäá å_äéáöÝñïõóá!\n".
"Ôåëåõôáßá öïñÜ Þñèåò åäþ ùò " .$row->{host}. " óôéò "
..$row->{date}. " !!\n".
"Óý_ïëéêÝò Þñèåò åäþ " .$row->{hostcount}. " öïñÝò !!!\n".
"Ôåëåõôáßá åßäåò ôï êåßìå_ï { " .$row->{script}. " }\n".
"Ðïéü êåßìå_ï èá ìåëåôÞóåéò áõôÞ_ ôç_ öïñÜ !?";
}
When i have '\n' then my script print blank lines, if i change it to
<br> it does not, why?
Also i have to use these if i want my script to print ok the fiel it
opens. maybe i dotn have to when <br> works!
$data =~ s/\n/\\n/g;
$data =~ s/"/\\"/g;
$data =~ tr/\cM//d;
| |
|
| Nikos wrote:
The $data then would pass to the index.html which is a template file and
then $data would be printed by javascript like this:
var textToShow = "<TMPL_VAR name=data>";
So if it contains chars like ' or " or \ or / that would be a problem right?
At least in my old index.pl (the one with cgi.pm) there was problem
printing it.
What can i do?
| |
| Gunnar Hjalmarsson 2005-04-26, 8:57 pm |
| Nikos wrote:
<snip>
> return "Êáëþò Þëèåò " .$host. "! ×áßñïìáé ðïõ âñßóêåéò ôç_
> óåëßäá å_äéáöÝñïõóá!\n".
> "Ôåëåõôáßá öïñÜ Þñèåò åäþ ùò " .$row->{host}. " óôéò "
> .$row->{date}. " !!\n".
> "Óý_ïëéêÝò Þñèåò åäþ " .$row->{hostcount}. " öïñÝò !!!\n".
> "Ôåëåõôáßá åßäåò ôï êåßìå_ï { " .$row->{script}. " }\n".
> "Ðïéü êåßìå_ï èá ìåëåôÞóåéò áõôÞ_ ôç_ öïñÜ !?";
> }
>
> When i have '\n' then my script print blank lines, if i change it to
> <br> it does not, why?
The code you posted doesn't print anything AFAICS.
Nikos, you seem to try using this group as a substitute for own
studying. As you should have understood by now, that's not appreciated.
Please take a step back and start reading about the basics of HTML and
CGI. As regards CGI scripts in Perl, you can find a few online tutorials
at http://cgi.resourceindex.com/Docume.../CGI_Tutorials/
When you come back here, please respect the posting guidelines and try
to express yourself clearly. For instance, if a program does not behave
as you had expected, write a *small* but *complete* program that
illustrates just that behaviour (i.e. don't post a lot of code that
irrelevant to the problem in question).
If you do so, you'll be welcome to ask questions here.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
|
|
|
|