Help with error 500, but compiles and runs on my server and syntex checks out

Discussion in 'Perl Misc' started by froil, Mar 8, 2006.

  1. froil

    froil Guest

    When i run this on my box it works fine. no errors, but when i upload
    it to the server, it keeps giving me error 500 premature end of script.

    i know that most likely it is some stupid little mistake, but i have
    looked over this for hours and can't find it. Seems to complie and run
    #!/usr/bin/perl
    #newpage.cgi
    use warnings;
    use strict;
    use DBI;
    use CGI qw:)standard);
    use CGI::Carp qw(fatalsToBrowser);
    my $username = '?';
    my $password = '?';
    my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
    Print_Html_Top();
    Get_Descriptions();
    Print_Html_Bottom();
    sub Print_Row{
    my $rec = shift;
    my $currentpage = $rec->{currentpages};
    print qq(<tr><td><input type=radio name=pagename
    value=$currentpage>$currentpage</td></tr>);
    }
    sub Get_Descriptions{
    my $DBH = DBI->connect( $data_source, $username, $password )
    or die "Error: $DBI::errstr\n";
    my $sth_fetch=
    $DBH->prepare( qq(SELECT * FROM pages)) or die
    $DBH->errstr;
    $sth_fetch->execute();
    while( my $ptr = $sth_fetch->fetchrow_hashref){
    Print_Row($ptr);
    }
    }
    sub Print_Html_Top{
    print header;
    print<<EOT;
    <html><head><title>Add Files</title></head>
    <body>
    <Form name="upload" Method="Post"
    Action="/cgi-bin/uploadeasy1.cgi" Enctype="multipart/form-data">
    <center><h2>Add Pictures</h2></center>
    <center><font size=3>Select page to add to, or type in
    name of new page</font></center>
    <center><Table Border=1>
    <tr><td>New Page Name: </td>
    <td><input type="text" name="newpage"></td></tr>
    EOT
    }
    sub Print_Html_Bottom {
    print<<EOT;
    <tr>
    <td>Choose File: </td>
    <td><input type="file" Name="filename"></td>
    </tr>
    <tr>
    <td>Description: </td>
    <td><input type="text" Name="description" rows="1"
    cols="40"></td></tr>
    <tr><td><input type="submit" Name="submit" Value="Save
    File"></td></tr></table></center>
    </form>
    </body></html>
    EOT
    }
     
    froil, Mar 8, 2006
    #1
    1. Advertising

  2. froil

    Big and Blue Guest

    Re: Help with error 500, but compiles and runs on my server and syntexchecks out

    froil wrote:
    > When i run this on my box it works fine. no errors, but when i upload
    > it to the server, it keeps giving me error 500 premature end of script.


    So what does the error log of the Web server say?

    You have a lot of die()s in there that are never going to send any info
    back to a Web client. Have you considered writing a kill_me function to
    actually format an actual HTML page containing the error text (so that you
    don't even need to read the logs) and installing it as $SIG{_DIE_}?

    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
     
    Big and Blue, Mar 8, 2006
    #2
    1. Advertising

  3. froil

    John Bokma Guest

    Big and Blue <> wrote:

    > You have a lot of die()s in there that are never going to send any
    > info
    > back to a Web client. Have you considered writing a kill_me function
    > to actually format an actual HTML page containing the error text (so
    > that you don't even need to read the logs) and installing it as
    > $SIG{_DIE_}?


    Maybe you should find out what

    use CGI::Carp qw(fatalsToBrowser);

    does?

    Personally I would put it above all other non-pragmatic use's.

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    I ploink googlegroups.com :)
     
    John Bokma, Mar 8, 2006
    #3
  4. Gunnar Hjalmarsson, Mar 8, 2006
    #4
  5. froil wrote:
    > When i run this on my box it works fine. no errors, but when i upload
    > it to the server, it keeps giving me error 500 premature end of
    > script.


    So, why don't you follow the advice in the FAQ ('perldoc -q 500'):

    "My CGI script runs from the command line but not the browser. (500
    Server Error)"

    jue
     
    Jürgen Exner, Mar 8, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikhil Patel

    client script syntex error

    Nikhil Patel, Oct 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,166
    Nikhil Patel
    Oct 7, 2004
  2. Thomas G. Marshall
    Replies:
    5
    Views:
    862
    Thomas G. Marshall
    Aug 6, 2004
  3. Rock
    Replies:
    4
    Views:
    463
    Jim Langston
    Nov 20, 2005
  4. Replies:
    4
    Views:
    344
    Peter
    Jun 20, 2006
  5. PerlFAQ Server
    Replies:
    0
    Views:
    425
    PerlFAQ Server
    Mar 15, 2011
Loading...

Share This Page