Hiya. I'm new here, and I'm a just staring rogrammer (14 years from Holland :)). Anyway, I'm stuck up with a problem. My guestbook doesn't show up, in fact, it gives a 500 error. Runned on localhost, nothing working, runned on my server (and executed), no luck either. My OS is Win98 and the server's is Linux, so no chmod probs.

Maybe you could try this? I made a simple script, only printing text to see if it works, but it doesn't. Other scripts do, however. On that script (just the printing one), I changed to Perl interpreter path, but....

#!usr/bin/perl -w use warnings; # use Module warnings (for better error checking) use CGI; # use Module CGI (enhanced CGI functions) use strict; # stricter acces for subs, references and vars without sco +pe (nice for error trapping) use Fcntl; # Module used for system operations (mostly UNIX). This is +one I need for flock() use vars qw($q); print "Content-type: text/html\n\n"; # To let the CGI Interface run, d +eclare content-type # SET VARIABLES !!! # $use_flock = 0; # set to 0 if you don't use flock(), otherwise use 1 $q = new CGI; # Parameters: (we will let CGI.PM handle form-processing) my $query_name = $q->param('name'); my $query_email = $q->param('email'); my $query_msg = $q->param('message'); # prepare file acces mkdir('messages', 0777); # make directory called message, permissions +set to ALL ACCES # CALL SUBROUTINES # &open_file; &write_file; # END CALL SUBROUTINES # sub open_file { my (@filecontents); opendir(MSGDIR, "/messages"); @files = readdir(MSGDIR); close(MSGDIR); foreach $file (@files) { open(OPENFILE, "/messages/$file"); if ($use_flock == 1) { flock(OPENFILE, LOCK_NB); } # use flock() when value set to 1 @filecontents = <OPENFILE>; if ($use_flock == 1) { flock(OPENFILE, LOCK_UN); } # don't use flock() when value set to 0 close(OPENFILE); print<<__HTML__; foreach $fcontent (@filecontents) { print($fcontent); } __HTML__ } } # end open_file sub write_file { &HTML; my ($writefile) = "msg" . $$ . ".txt"; # construct filename; $ +$ = process ID if (defined($query_name, $query_email, $query_message)) { $def = 1; } else { $def = 0; } if ($def == 1) { open(WRITEFILE, ">$writefile") or die("Can't open $writef +ile. \n Error:\n $!"); print WRITEFILE, $query_name; print WRITEFILE, $query_email; print WRITEFILE, $query_msg; close(WRITEFILE); } else { print("You did not enter any valid input.\n Pleas +e go back to fill them in."); } } # end write_file sub HTML { print<<HTML; <html> <head> <title>Guestbook - Test #0.01 - Beta 0.01</title> </head> <body> <center> <font face="Tahoma"> Please fill in a messsage.<Br><br><br><br> <form method="POST"> <b>Name:</b> <input type="text" value="name"><br> <b>Email:</b> <input type="text" value="email"><br><br> <b>Message:</b> <Br><br><textarea rows="5" cols="25"></textarea><br> <Br><button type="submit">Send Message!</button> </form> </font> <center> </body> </html> HTML; } 1;

Edit by tye, remove PRE tags, add CODE and READMORE tags.


In reply to Guestbook Problem - 500 Error [ISE] by MystikGotan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.