Single comments causing runtime problems

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?
gregreeveAsked:
Who is Participating?
 
maneshrConnect With a Mentor Commented:
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
 
ozoCommented:
Is it the perl script that blows up, or the browser?
In what way does it blow up?
0
 
gregreeveAuthor Commented:
its the perl script that complains about there being a non terminated single quote.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
gregreeveAuthor Commented:
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
 
gregreeveAuthor Commented:
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
 
maneshrCommented:
Glad to have been of help to you :-)

Rgds
0
 
ozoCommented:
How did putting $comment in quotes cause a problem?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.