Solved

Single comments causing runtime problems

Posted on 2000-04-19
7
210 Views
Last Modified: 2010-03-05
I have a form that calls a perl script.  When the user enters a single comment character it causes my perl script to blow up when I try printing that field.  So my code looks like:

$comment= $query->param('comment');

and later on

print $comment;

I know it must be sonething simple - any ideas?
0
Comment
Question by:gregreeve
  • 3
  • 2
  • 2
7 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 50 total points
ID: 2730591
did you print the Content-type: MIME header before you printed $comment??

here is a code that i used and it works fine with ' quotes.

i used POST and GET and it worked fine!!
Also instead of input type=text i used <textarea>. Again all was ok.

=========test.html
<FORM method=POST action="/cgi-bin/test.pl">
<input type=text name=comment>
<P>
<input type=submit>
</FORM>
=========test.pl
#!/usr/local/bin/perl

use CGI;
$query=new CGI;

$comment= $query->param('comment');

print "Content-type: text/html\n\n";
print $comment,"\n";
0
 
LVL 84

Expert Comment

by:ozo
ID: 2731723
Is it the perl script that blows up, or the browser?
In what way does it blow up?
0
 

Author Comment

by:gregreeve
ID: 2733623
its the perl script that complains about there being a non terminated single quote.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gregreeve
ID: 2733627
sorry - I need to be clearer.

I am accepting input, printing it to the mailer (sending mail) and then I print a 'Location:http//.....' at the end to send the user to a web page.

I will try the Content-type though...

Greg
0
 

Author Comment

by:gregreeve
ID: 2733666
Thanks - my mistake was to put the $comment in quotes before as a part of the print string.  Now it works fine.

Many Thanks - enjoy your points!
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2740417
Glad to have been of help to you :-)

Rgds
0
 
LVL 84

Expert Comment

by:ozo
ID: 2740735
How did putting $comment in quotes cause a problem?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is there a file descriptor created for logfile using by logmsg within Perl script 4 140
Perl Sort Question 4 141
combine multiple lines 2 74
Export Variables in Perl 3 108
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question