Well im new to scripting and i attepmted to right a basic guest book that i am going to one day turn into a full blown forum. I was just wondering if any one can point out what i did wrong on this script. Please HELP!<br /><br />#!/usr/bin/perl<br />use CGI;<br /> <br />my $cgi = CGI->new();<br /> <br /><br />my $name = $cgi->param('name');<br />my $msg = $cgi->param('msg');<br /> <br /><br />if (length ($name) > 50 || length ($msg) > 2000) {<br /> print "Content-type: html/text\n\n";<br /> print "Your name or message was too long.";<br /> exit;<br />}<br /> <br /><br />$msg =~ s/[\n\r]/<br>/g;<br /> <br /><br />open (LOG, ">>msg_log.txt") || die ("Can't open msg_log.txt: $!");<br />flock (LOG);<br />print LOG "$name wrote: $msg\n";<br />close (LOG);<br /> <br />print "Content-type: html/text\n\n";<br />print "Thanks for your message";<br />exit;<br /><br />I suck at de-buggin and cant seem to figure it out. so please help. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/kicking.gif" style="vertical-align:middle" emoid=":dance:" border="0" alt="kicking.gif" /><!--content-->
What are you getting for an error message?<!--content-->
pre mature end of script headers. dont tell you much cept that the script dont work].<!--content-->
It's a pretty common error. But your script looks fine.<br /><br />I would be looking into permissions at this point. Make sure your perl script is setl to 755. All executing perl scripts need this to work.<br /><br />I'll try it out on my end just in case that's not the error.<br /><br />Good luck!<br /><br />Bill<!--content-->
I de-bugged your script. It was about 99% there and just had a few syntax errors.<br /><br />I'll give you a choice, you can give it a shot on your own, or I can give you the answer. If you're intending on building anything significant I suggest giving it a try with some guidance. I usually learn better from doing things myself.<br /><br />Here's a hint for you. Insert the following bolded line into the top of your code so you can see more descriptive errors:<br /><br />**********************<br />#!/usr/bin/perl<br />use CGI;<br /><br />my $cgi = CGI->new();<br /><b>use CGI::Carp qw(fatalsToBrowser);</b><br /><br />my $name = $cgi->param('name');<br />my $msg = $cgi->param('msg');<br />**********************<br /><br /><br />Give that a try and see if you can figure the rest out. If you get suck again, you can always ask for another hint.<br /><br />Good luck!<br /><br />Bill<!--content-->
hmmmm..well i tried that and got an error again. Another hint? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
i bewlive i found the problum but it is a super major one. for some reason i cannot get a param to print out no matter how i try it. ive tryed:<br /><br />print "Content-type: text/html\n\n";<br /><br />print param('name');<br />and<br />$name = param('name');<br />print $name;<br />and<br />$CGI = cgi->new;<br />$name=$cgi->param('name');<br />print $name;<br /><br />im not sure why. and i know about permissions.<!--content-->
Hi!<br /><br />Sorry for my late response. I had THOUGHT I subscribed to this topic ... I guess I hadn't.<br /><br />This is a code snip from one of my progams in production:<br /><br />*****************************<br />#!/usr/bin/perl<br /><br />use CGI;<br />use CGI::Carp qw(fatalsToBrowser);<br />$query = new CGI;<br />$pnum=$query->param('pnum');<br />******************************<br /><br />I assure you that this does work. If you are finding that you still arn't getting anything from your form to print out in your script you can check:<br /><br />1) The "name" value in your form. Make sure that it is exactly what you have specified.<br />2) The "action" for your form. Make sure that the script form action is exactly the same as the name of your script.<br />3) Double check permissions, just in case. If you are able to print anything, you're probably Ok.<br />4) How did you get your script where it is? If your script was put up using FTP it MUST be in ASCII format. Binary format will not work. If you're not sure, delete your script and re-upload it in the correct format. FrontPage can mess this up for you too. Don't use it for scripts.<br /><br />If none of this works, you might want to send me the files (your HTML form and perl script file) and I'll figure it out.<br /><br />We'll get through this!<br /><br />PS - Good on-line reference for you: <a href="http://iis1.cps.unizar.es/Oreilly/perl/" target="_blank">http://iis1.cps.unizar.es/Oreilly/perl/</a><br /><br />If there's anything you need to learn, it's probably in that link.<br /><br />Good luck!<!--content-->
got a 500 error that time. went threw your check list and everything. IDK<!--content-->
Do you want to send me your files?<br /><br />I'll take a look at them.<br /><br />Bill<br />[email protected]<!--content-->
One last thing ...<br /><br />I'm calling it a night ... but send the files and I will look at them tomorrow.<br /><br />See ya!<br /><br />Bill<!--content-->
What are you getting for an error message?<!--content-->
pre mature end of script headers. dont tell you much cept that the script dont work].<!--content-->
It's a pretty common error. But your script looks fine.<br /><br />I would be looking into permissions at this point. Make sure your perl script is setl to 755. All executing perl scripts need this to work.<br /><br />I'll try it out on my end just in case that's not the error.<br /><br />Good luck!<br /><br />Bill<!--content-->
I de-bugged your script. It was about 99% there and just had a few syntax errors.<br /><br />I'll give you a choice, you can give it a shot on your own, or I can give you the answer. If you're intending on building anything significant I suggest giving it a try with some guidance. I usually learn better from doing things myself.<br /><br />Here's a hint for you. Insert the following bolded line into the top of your code so you can see more descriptive errors:<br /><br />**********************<br />#!/usr/bin/perl<br />use CGI;<br /><br />my $cgi = CGI->new();<br /><b>use CGI::Carp qw(fatalsToBrowser);</b><br /><br />my $name = $cgi->param('name');<br />my $msg = $cgi->param('msg');<br />**********************<br /><br /><br />Give that a try and see if you can figure the rest out. If you get suck again, you can always ask for another hint.<br /><br />Good luck!<br /><br />Bill<!--content-->
hmmmm..well i tried that and got an error again. Another hint? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
i bewlive i found the problum but it is a super major one. for some reason i cannot get a param to print out no matter how i try it. ive tryed:<br /><br />print "Content-type: text/html\n\n";<br /><br />print param('name');<br />and<br />$name = param('name');<br />print $name;<br />and<br />$CGI = cgi->new;<br />$name=$cgi->param('name');<br />print $name;<br /><br />im not sure why. and i know about permissions.<!--content-->
Hi!<br /><br />Sorry for my late response. I had THOUGHT I subscribed to this topic ... I guess I hadn't.<br /><br />This is a code snip from one of my progams in production:<br /><br />*****************************<br />#!/usr/bin/perl<br /><br />use CGI;<br />use CGI::Carp qw(fatalsToBrowser);<br />$query = new CGI;<br />$pnum=$query->param('pnum');<br />******************************<br /><br />I assure you that this does work. If you are finding that you still arn't getting anything from your form to print out in your script you can check:<br /><br />1) The "name" value in your form. Make sure that it is exactly what you have specified.<br />2) The "action" for your form. Make sure that the script form action is exactly the same as the name of your script.<br />3) Double check permissions, just in case. If you are able to print anything, you're probably Ok.<br />4) How did you get your script where it is? If your script was put up using FTP it MUST be in ASCII format. Binary format will not work. If you're not sure, delete your script and re-upload it in the correct format. FrontPage can mess this up for you too. Don't use it for scripts.<br /><br />If none of this works, you might want to send me the files (your HTML form and perl script file) and I'll figure it out.<br /><br />We'll get through this!<br /><br />PS - Good on-line reference for you: <a href="http://iis1.cps.unizar.es/Oreilly/perl/" target="_blank">http://iis1.cps.unizar.es/Oreilly/perl/</a><br /><br />If there's anything you need to learn, it's probably in that link.<br /><br />Good luck!<!--content-->
got a 500 error that time. went threw your check list and everything. IDK<!--content-->
Do you want to send me your files?<br /><br />I'll take a look at them.<br /><br />Bill<br />[email protected]<!--content-->
One last thing ...<br /><br />I'm calling it a night ... but send the files and I will look at them tomorrow.<br /><br />See ya!<br /><br />Bill<!--content-->