Evilseperoth Posted February 25, 2004 Share Posted February 25, 2004 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! #!/usr/bin/perl use CGI; my $cgi = CGI->new(); my $name = $cgi->param('name'); my $msg = $cgi->param('msg'); if (length ($name) > 50 || length ($msg) > 2000) { print "Content-type: html/text\n\n"; print "Your name or message was too long."; exit; } $msg =~ s/[\n\r]/<br>/g; open (LOG, ">>msg_log.txt") || die ("Can't open msg_log.txt: $!"); flock (LOG); print LOG "$name wrote: $msg\n"; close (LOG); print "Content-type: html/text\n\n"; print "Thanks for your message"; exit; I suck at de-buggin and cant seem to figure it out. so please help. Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 26, 2004 Share Posted February 26, 2004 What are you getting for an error message? Quote Link to comment Share on other sites More sharing options...
Evilseperoth Posted February 27, 2004 Author Share Posted February 27, 2004 pre mature end of script headers. dont tell you much cept that the script dont work]. Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 27, 2004 Share Posted February 27, 2004 It's a pretty common error. But your script looks fine. 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. I'll try it out on my end just in case that's not the error. Good luck! Bill Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 27, 2004 Share Posted February 27, 2004 I de-bugged your script. It was about 99% there and just had a few syntax errors. 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. Here's a hint for you. Insert the following bolded line into the top of your code so you can see more descriptive errors: ********************** #!/usr/bin/perl use CGI; my $cgi = CGI->new(); use CGI::Carp qw(fatalsToBrowser); my $name = $cgi->param('name'); my $msg = $cgi->param('msg'); ********************** 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. Good luck! Bill Quote Link to comment Share on other sites More sharing options...
Evilseperoth Posted February 28, 2004 Author Share Posted February 28, 2004 hmmmm..well i tried that and got an error again. Another hint? Quote Link to comment Share on other sites More sharing options...
Evilseperoth Posted February 28, 2004 Author Share Posted February 28, 2004 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: print "Content-type: text/html\n\n"; print param('name'); and $name = param('name'); print $name; and $CGI = cgi->new; $name=$cgi->param('name'); print $name; im not sure why. and i know about permissions. Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 28, 2004 Share Posted February 28, 2004 Hi! Sorry for my late response. I had THOUGHT I subscribed to this topic ... I guess I hadn't. This is a code snip from one of my progams in production: ***************************** #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); $query = new CGI; $pnum=$query->param('pnum'); ****************************** 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: 1) The "name" value in your form. Make sure that it is exactly what you have specified. 2) The "action" for your form. Make sure that the script form action is exactly the same as the name of your script. 3) Double check permissions, just in case. If you are able to print anything, you're probably Ok. 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. 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. We'll get through this! PS - Good on-line reference for you: http://iis1.cps.unizar.es/Oreilly/perl/ If there's anything you need to learn, it's probably in that link. Good luck! Quote Link to comment Share on other sites More sharing options...
Evilseperoth Posted February 29, 2004 Author Share Posted February 29, 2004 got a 500 error that time. went threw your check list and everything. IDK Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 29, 2004 Share Posted February 29, 2004 Do you want to send me your files? I'll take a look at them. Bill bill@hcsuperstores.com Quote Link to comment Share on other sites More sharing options...
HCSuperStores Posted February 29, 2004 Share Posted February 29, 2004 One last thing ... I'm calling it a night ... but send the files and I will look at them tomorrow. See ya! Bill Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.