49 users online (0 members and 49 guests)  


  Results 1 to 6 of 6

Related

  1. Script Returns HTTP Error 405    Forum: CGI Perl Forum
    Replies: 4
  2. Web-edit Script Error    Forum: PHP Forum
    Replies: 5
  3. Perl script error..    Forum: CGI Perl Forum
    Replies: 1
  4. Premature end of script headers error    Forum: CGI Perl Forum
    Replies: 1
  5. PHP Upload script error    Forum: PHP Forum
    Replies: 14
  1. #1
    sammysoil's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    3

    Wondering why this script gets a 500 error

    Could anyone tell me where I'm going wrong with this script? When I link to it, it just comes up with a 500 error:

    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<head>\n";
    print "<LINK REL=stylesheet HREF="mystylesheet" TYPE="text/css">\n";
    print "</head>\n";
    print "<BODY>\n";
    print "<h1 align="center">The World Has Been Bought </h1>";
    print "<p align="center">\n";
    print " lots of text\n";
    print "<br><br>7/10/07\n";
    print "</p>\n";
    print "<FORM METHOD="POST" ACTION="theurl.pl";
    print "<h3>Comment</h3>\n";
    print "<PRE>\n";
    print " Name: <INPUT TYPE="text" NAME="name" SIZE="40">\n";
    print "<br>\n";
    print "<TEXTAREA NAME="comments" ROWS=6 COLS=60></TEXTAREA>\n";
    print "<INPUT TYPE="submit" VALUE="Post">\n";
    print "</pre>\n"; 
    print "</form>\n";
    print "<table border="1" align="center">\n";
    print "</table></body></html>\n";
    Last edited by vinyl-junkie; 09-16-2007 at 09:31 PM. Reason: Added code tags

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Wondering why this script gets a 500 error

    I'm not versed in Perl, but I do note that you don't seem to escape special characters. For example, this statement:

    Code:
    print "<LINK REL=stylesheet HREF="mystylesheet" TYPE="text/css">\n";
    needs to have its special characters escaped, like so:

    Code:
    print "<LINK REL=stylesheet HREF=\"mystylesheet\" TYPE=\"text/css\">\n";
    You should check the rest of your code to see if it has the same problem.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    sammysoil's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    3

    Re: Wondering why this script gets a 500 error

    Thank you very much, I'll check for that.

  4. #4
    CGI_Newbie's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    4

    Re: Wondering why this script gets a 500 error

    Don't know if you figured this out yet, but you might want to try two things...

    one, the location for perl on your server might not be at
    #!/usr/bin/perl

    it might be at #!/usr/local/bin/perl

    also, try adding warnings to the script...that's what got mine working..

    #!/usr/bin/perl -w

  5. #5
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: Wondering why this script gets a 500 error

    Overally the script above is poorly written. There is no need to enclose all your html lines like this... i.e. print "<b>hello</b>"; etc...
    Perl will often print these correctly anyway unless they are put in qw or qq i.e. "print qw(<b>hello</b>);
    This is how you should do it...
    print "Content-type: text/html\n\n";
    print <<"HTML code";
    <HTML>
    <HEAD>
    <title>HTML Page</title>
    </HEAD>
    <BODY>
    YOUR MAIN HTML CODE
    </BODY>

    </HTML>
    HTML code
    print "";

    Chris

  6. #6
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: Wondering why this script gets a 500 error

    I forgot to mention that \n are ignored for CGI/Perl scripts running for the Web. Unless you are printing to an external file.
    If you aren't printing HTML code and you want to start a new line, you can use the HTML tag <p> or <br>
    i.e.
    print "<p>Hello";
    print "<p>Bye";



Tags for this Thread