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

F

froil

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
}
 
B

Big and Blue

froil said:
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_}?
 
J

John Bokma

Big and Blue said:
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.
 
J

Jürgen Exner

froil said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top