Getting error 500 when removing sub call

F

froil

i am running the script below and when i have the line Get_Page_Options
( ); in the script it ofcourse gives me the error that the sub doesn't
exsist, but when i take that line out, or just make the program in to a
sub with that name, it give me an error 500. Please help!!
DOESN'T WORK ERROR 500
#!/usr/bin/perl -wT
use strict;
use DBI;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
my $Url_Path = "../uploads";
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $PageName =param('PageName');
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $DBH = DBI->connect( $data_source, $username, $password ) or die
"Error: $DBI::errstr\n";
my $sql = "SELECT * FROM pages WHERE PageName = ?";
my $sth = $DBH->prepare($sql);
$sth->execute("$PageName");
print DBI::dump_results($sth);
$DBH->disconnect;

NO ERROR 500
#!/usr/bin/perl -wT
use strict;
use DBI;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
my $Url_Path = "../uploads";
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $PageName =param('PageName');
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $DBH = DBI->connect( $data_source, $username, $password ) or die
"Error: $DBI::errstr\n";
Get_Background_Options();
$DBH->disconnect;
sub Get_Background_Options {
my $sql = "SELECT * FROM pages WHERE PageName = ?";
my $sth = $DBH->prepare($sql);
$sth->execute("$PageName");
print DBI::dump_results($sth);
}
 
F

froil

sorry the no error script is
#!/usr/bin/perl -wT
use strict;
use DBI;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
my $Url_Path = "../uploads";
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $PageName =param('PageName');
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $DBH = DBI->connect( $data_source, $username, $password ) or die
"Error: $DBI::errstr\n";
Get_Background_Options();
my $sql = "SELECT * FROM pages WHERE PageName = ?";
my $sth = $DBH->prepare($sql);
$sth->execute("$PageName");
print DBI::dump_results($sth);
 
T

Tad McClellan

froil said:
it give me an error 500.


perldoc -q 500

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

my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $PageName =param('PageName');
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';


Why are you setting $username, $password and $data_source twice there?

$sth->execute("$PageName");


$sth->execute( $PageName );


perldoc -q vars

What's wrong with always quoting "$vars"?
 
B

Bart Van der Donck

froil said:
sorry the no error script is
#!/usr/bin/perl -wT
use strict;
use DBI;
use CGI qw:)standard);
use CGI::Carp qw(fatalsToBrowser);
my $Url_Path = "../uploads";
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $PageName =param('PageName');
my $username = 'jilesfr_cgi';
my $password = 'upload';
my $data_source = 'DBI:mysql:jilesfr_pictures:69.6.255.192:3306';
my $DBH = DBI->connect( $data_source, $username, $password ) or die
"Error: $DBI::errstr\n";
Get_Background_Options();
my $sql = "SELECT * FROM pages WHERE PageName = ?";
my $sth = $DBH->prepare($sql);
$sth->execute("$PageName");
print DBI::dump_results($sth);

Froil !!

Please think twice before you reveal your real username and password.
I'ld strongly suggest to change it immediately.

When you leave out line

Get_Background_Options();

the above script will work fine as CGI. In order to avoid Error 500,
you should make sure your programme has the right permissions to
execute.

Variables $username, $password and $data_source are declared twice in
your code. No need for that.

It's good practice to close DBI connections after you're done. In your
code, I recommend to add the following 2 lines at the end:

$sth->finish;
$DBH->disconnect;
 

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,705
Latest member
Stefkari24

Latest Threads

Top