
Aaargh
New User
Jan 6, 2011, 8:58 AM
Post #1 of 2
(438 views)
|
|
Newbie question
|
Can't Post
|
|
Hi all. I'm new to programming and am having a bit of trouble getting a very simple .pl script to work. It's for a message board, and is as basic as it gets, yet it keeps returning a 500 error. I checked with my host server and they sent me back something I don't understand. ---------------------------------------------------------------------- Here's my script: #!/usr/bin/perl #post_message.pl $buffer=$ENV{'QUERY_STRING'}; $buffer =~ tr/+/ /; $buffer =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $buffer =~ s/<!--(.|\n)*-->/ /g; $buffer =~ tr/\\|[|]|<|!|"|$|{|}|*|#|'|>|||;|%/ /; @pairs = split(/&/,$buffer); foreach $pair(@pairs){ ($key,$value)=split(/=/,$pair); $formdata{$key}.="$value"; } $yourname=$formdata{'yourname'}; $email=$formdata{'email'}; $subject=$formdata{'subject'}; $message=$formdata{'message'}; open(INFO, ">>message_board.txt"); # Open for appending print INFO "$yourname|$email|$subject|$message\n"; close (INFO); open(INFO, "message_board.txt"); # Open db for reading and display @array=<INFO>; close (INFO); print "Content-type:text/html\n\n"; #Follow with blank line print "<html>\n"; print "<head><title>Message Board</title>\n"; print "<style type="text/css">\n"; print "h2\{font-family: Arial;font-style : normal ;font-size : 12pt; font-weight :bold;text-align :center\}\n"; print "td\{font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal \}\n"; print "p\{ font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal;text-align :left; width : 40em \}\n"; print "</style>\n"; print "</head>\n"; print "<body>\n"; print "<div align=\"center\">\n"; print "<h2>Message Board</h2>\n"; print "<table width=\"550\" cellpadding=\"5\" cellspacing=\"0\" border=\"1\">\n"; foreach $line (@array){ ($yourname,$email,$subject,$message)=split(/\|/,$line); print "<tr><td>\n"; print "Posted by: $yourname <a href="mailto:$email">Return Message by Email</a><br>\n"; print "Subject:$subject<br>\n"; print "<br>\n"; print "Message:<br>\n"; print "<p>$message</p>\n"; print "</td></tr>\n"; } print "</table>\n"; print "<br><br>\n"; print "<a href=\"./message_brd.html\">Post a New Message</a>\n"; print "</div>\n"; print "</body>\n"; print "</html>\n"; ------------------------------------------------------------------- HERE'S WHAT MY HOST SERVER SAYS: Bareword found where operator expected at ./post_message.pl line 31, near ""<style type="text" (Missing operator before text?) String found where operator expected at ./post_message.pl line 31, near "css">\n"" Bareword found where operator expected at ./post_message.pl line 46, near ""Posted by: $yourname <a href="mailto" (Missing operator before mailto?) String found where operator expected at ./post_message.pl line 46, near "$email">Return Message by Email</a><br>\n"" (Missing operator before ">Return Message by Email</a><br>\n"?) syntax error at ./post_message.pl line 31, near ""<style type="text" syntax error at ./post_message.pl line 46, near ""Posted by: $yourname <a href="mailto" Execution of ./post_message.pl aborted due to compilation errors. ----- This appears to be due to embedding double-quotes in a double-quoted string. ---------------------------------------------------------------- Anybody care to decode this for me and explain what I did wrong and how to fix it? Thanks a million times over.
|