CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Mysterious 500 error

 



no longer fuzzy
Deleted

Aug 10, 2000, 8:45 AM

Post #1 of 7 (713 views)
Mysterious 500 error Can't Post

Hi. this is my first time posting here, so I hope this is in the correct forum.

I'm getting an internal server error with this script, but I can't seem to spot the problem. I ran perl -cw and didn't find any errors, so I thought it was probably a problem with my form. I set mode 666 on my .dax files and 755 on the script itself, so I don't think it's that. Maybe a fresh set of eyes can spot it, since mine are getting sore from squinting. Here is the form:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="000000" TEXT="FF0000">
<CENTER>
<TABLE WIDTH=80% BORDER=0>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<P><FONT SIZE=+2>Add your link!<BR></FONT></P>
</TD>
</TR>
<TR>
<TD COLSPAN=2>
<P>I find that trying to keep up with all of the new guilds that keep
appearing to be a pain, so I thought I'd just let you add your own link.
<BR></P>
</TD>
</TR>
<FORM ACTION="http://absolute.url.here/script.cgi" METHOD="POST">
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<P>The name of your site</P>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<INPUT TYPE="TEXT" NAME="sitename">
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<P>The URL of your site</P>
</TD>
<TD ALIGN="CENTER">
<P>The URL of your banner</P>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<INPUT TYPE="TEXT" NAME="siteurl" VALUE="http://">
</TD>
<TD ALIGN="CENTER">
<INPUT TYPE="TEXT" NAME="bannerurl" VALUE="http://">
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<P>A brief description of your site</P>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<TEXTAREA NAME="description" ROWS=5 COLS=60 WRAP="VIRTUAL"></TEXTAREA>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<P>Email address of the webmaster</P>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<INPUT TYPE="TEXT" NAME="email">
</TD>
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN=2>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML><HR></BLOCKQUOTE>

and here is the whole script:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
#!/usr/bin/perl
print "Content-type:text/html\n\n;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name}=$value;
}
open(OUTF, ">>links.dax" or dienice ("Could not write to link database: $!\n");
flock(0,2);
seek(OUTF,0,2);
print OUTF "$FORM{'sitename'}|$FORM{'siteurl'}|$FORM{'bannerurl'}|$FORM{'description'}\n";
close(OUTF);

open(EMAILADDY, ">>email.dax" or dienice ("Could not write to email database: !$\n");
flock(0,2);
seek(EMAILADDY,0,2);
print EMAILADDY "$FORM{'sitename'}|$FORM{'email'}\n";
close(EMAILADDY);

print <<EndHead;
!html snipped
EndHead

open (INF, "links.dax") or dienice ("Could not open link database for reading: !$\n");
seek(INF,0,0);
@data = <INF>;
close (INF);

foreach $n (@data) {
chomp ($n);
($name,$url,$banner,$desc) = split(/\|/,$n);
print "<tr><td align='center'>$name</td></tr>\n";
print "<tr><td align='center'><a href='url'><img src='$banner' border=0 alt='$name'></a></td></tr>\n";
print "<tr><td align='center'>$desc</td></tr>\n";
}

print <<EndTail;
!html snipped
EndTail

sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
<HR></BLOCKQUOTE>




[This message has been edited by no longer fuzzy (edited 08-10-2000).]


no longer fuzzy
Deleted

Aug 9, 2000, 10:40 PM

Post #2 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

Just went back and checked my code. All of those are typos in the post only. Use this code to check please:

#!/usr/bin/perl
print "Content-type:text/html\n\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name}=$value;
}
open(OUTF, ">>links.dax") or dienice ("Could not write to link database: $!\n");
flock(0,2);
seek(OUTF,0,2);
print OUTF "$FORM{'sitename'}|$FORM{'siteurl'}|$FORM{'bannerurl'}|$FORM{'description'}\n";
close(OUTF);

open(EMAILADDY, ">>email.dax") or dienice ("Could not write to email database: !$\n");
flock(0,2);
seek(EMAILADDY,0,2);
print EMAILADDY "$FORM{'sitename'}|$FORM{'email'}\n";
close(EMAILADDY);

print <<EndHead;
!html snipped
EndHead

open (INF, "links.dax") or dienice ("Could not open link database for reading: !$\n");
seek(INF,0,0);
@data = <INF>;
close (INF);

foreach $n (@data) {
chomp ($n);
($name,$url,$banner,$desc) = split(/\|/,$n);
print "<tr><td align='center'>$name</td></tr>\n";
print "<tr><td align='center'><a href='url'><img src='$banner' border=0 alt='$name'></a></td></tr>\n";
print "<tr><td align='center'>$desc</td></tr>\n";
}

print <<EndTail;
!html snipped
EndTail

sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}




[This message has been edited by no longer fuzzy (edited 08-11-2000).]


Jasmine
Administrator

Aug 9, 2000, 10:51 PM

Post #3 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

Problem #1 still exists in the second post of your code.


Jasmine
Administrator

Aug 10, 2000, 9:58 AM

Post #4 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

Problem #1:

print "Content-type:text/html\n\n; is missing an end-quote. Should be

print "Content-type:text/html\n\n";


Problem #2:

Missing close parens in open statements

open(OUTF, ">>links.dax" or dienice ("Could not write to link database: $!\n");

should be

open(OUTF, ">>links.dax") or dienice ("Could not write to link database: $!\n");

same problem with open(EMAILADDY, ">>email.dax" or dienice ("Could not write to email database: !$\n");

If possible, you should review your server's error logs to determine the cause of problems.


Jasmine
Administrator

Aug 11, 2000, 7:28 AM

Post #5 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

I've tried running the corrected program and it works without fail. If it's still failing for you, check permissions on your data files, and ensure that you have permission to write to the data directory/files.

If permissions are fine but it still doesn't work, check your server error logs -- that's the only source for a clear description of the problem after this. Or, run the program in your telnet prompt like this:

perl -w program.pl

and paste the error messages, if any.


no longer fuzzy
Deleted

Aug 11, 2000, 10:09 AM

Post #6 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

Doh! This is what I get for using the telnet program that comes with Windows, No copy and paste! I will edit the post.


no longer fuzzy
Deleted

Aug 12, 2000, 9:40 AM

Post #7 of 7 (713 views)
Re: Mysterious 500 error [In reply to] Can't Post

Well I'm almost embarassed to admit it, but I found the problem. There was a typo in the ACTION="address". Note to self: its .org, not .irg.

But thanks for your help anyway! Smile

[This message has been edited by no longer fuzzy (edited 08-12-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives