Hi again my great online assistants, just would like to say that i'm testing the script under unix , and after researches on the internet, i have realised that to resolve 500 Internal Server Error, we should put the script in cgi-bin directory, use of ASCII transfer mode, chmod 755 scriptname.cgi, and then login to unix and type ./scriptname.cgi.
I have connected to the database using mysql -u***** -p***** bugs
and i could have access to the database from mysql
I have done all of those but the internet page is always displaying 500 Internal Server Error.The server encountered an internal error or misconfiguratio n and was unable to complete your request.
and in unix i had the following:
Unrecognized character \x93 at ./perlcode1.cgi line 11.
But i think that the connection syntax is correct
what to do please?
Best Regards.
The code is the following:
[CODE=perl]
#!/usr/bin/perl -W
use DBI;
use DBD::mysql;
use strict;
use File::Copy;
use File::Path;
use File::Basename;
use Spreadsheet::Wr iteExcel::Big;
use Data::Dumper;
my $worksheet = ['Report.xls'];
my $dbh = DBI->connect( "DBI:mysql:dbna me=bugs:localho st", "carole", "carole", { RaiseError => 1, PrintError => 0, AutoCommit => 0 } )
or die("Error:$DBI ::errstr");
my $excel_file = "C:/Perl/Report.xls";
$query = qq{SELECT
b.bug_id, b.bug_file_loc, b.bug_severity, b.bug_status,
b.creation_ts, b.delta_ts, b.short_desc, b.op_sys,
b.priority, b.rep_plarform, b.version, b.component_id,
b.resolution, b.target_milest one, b.status_whiteb oard, b.votes,
b.keywords, b.last_diffed, b.everconfirmed , b.reporter_acce ssible,
b.cclist_access ible, b.estimated_tim e, b.remaining_tim e, b.deadline,
b.alias, pf.login_name, pd.name
FROM bugs b, profiles pf, products pd
WHERE bugs.assigned_t o = profiles.user_i d
AND bugs.product_id = products.id
ORDER BY bug_id};
my $sth = $dbh->prepare($query );
$sth->execute() or die $dbh->errstr;
while ( my $ref = $sth->fetchrow_hashr ef() ) {
print $ref ->{
'bug_id', 'assigned_to', 'bug_file_loc', 'bug_severity',
'bug_status', 'creation_ts', 'delta_ts', 'short_desc',
'op_sys', 'priority', 'product_id', 'rep_plarform',
'version', 'component_id', 'resolution', 'target_milesto ne',
'status_whitebo ard', 'votes', 'keywords', 'last_diffed',
'everconfirmed' , 'reporter_acces sible', 'cclist_accessi ble', 'estimated_time ',
'remaining_time ', 'deadline', 'alias', 'login_name',
'name'
},
"\n";
}
# -e checks to see if the file exists
if (-e $excel_file) {
#open Excel file
my $Book = $Excel->Workbooks->Open($excel_fi le);
$exists = "true";
} else {
$Book = $Excel->Workbooks->Open($excel_fi le);
$exists = "true";
} else {
$Book = $Excel->Workbooks->Add();
$exists = "false";
}
if ( $exists eq "true" ) {
$previousSheet = $Book->ActiveSheet;
$currentSheet = $Book->Worksheets->Add();
$Book->ActiveSheet->{Name} = "Report";
} else {
$previousSheet = 0;
}
#create the spreadsheet
$excel->output();
#sort data of worksheet – ASC or DESC
$excel->sort_data( "Report.xls ", 0, "ASC" );
#add headers to 'Report'
$excel->set_headers( 'Report.xls', [qw/Bugs report/] );
#print sheet-names
print join( ", ", $excel->sheets() ), "\n";
#get the result as a string
my $spreadsheet = $excel->output_as_stri ng();
#print result into a file and handle error
$excel->output_to_file ("Report.xls ") or die $excel->errstr();
if ( $exists eq "true" ) {
$Book->Save();
} else {
$Book->SaveAs("$excel _file") or die $!;
}
$sth->finish();
$dbh->disconnect() ;
[/CODE]
I have connected to the database using mysql -u***** -p***** bugs
and i could have access to the database from mysql
I have done all of those but the internet page is always displaying 500 Internal Server Error.The server encountered an internal error or misconfiguratio n and was unable to complete your request.
and in unix i had the following:
Unrecognized character \x93 at ./perlcode1.cgi line 11.
But i think that the connection syntax is correct
what to do please?
Best Regards.
The code is the following:
[CODE=perl]
#!/usr/bin/perl -W
use DBI;
use DBD::mysql;
use strict;
use File::Copy;
use File::Path;
use File::Basename;
use Spreadsheet::Wr iteExcel::Big;
use Data::Dumper;
my $worksheet = ['Report.xls'];
my $dbh = DBI->connect( "DBI:mysql:dbna me=bugs:localho st", "carole", "carole", { RaiseError => 1, PrintError => 0, AutoCommit => 0 } )
or die("Error:$DBI ::errstr");
my $excel_file = "C:/Perl/Report.xls";
$query = qq{SELECT
b.bug_id, b.bug_file_loc, b.bug_severity, b.bug_status,
b.creation_ts, b.delta_ts, b.short_desc, b.op_sys,
b.priority, b.rep_plarform, b.version, b.component_id,
b.resolution, b.target_milest one, b.status_whiteb oard, b.votes,
b.keywords, b.last_diffed, b.everconfirmed , b.reporter_acce ssible,
b.cclist_access ible, b.estimated_tim e, b.remaining_tim e, b.deadline,
b.alias, pf.login_name, pd.name
FROM bugs b, profiles pf, products pd
WHERE bugs.assigned_t o = profiles.user_i d
AND bugs.product_id = products.id
ORDER BY bug_id};
my $sth = $dbh->prepare($query );
$sth->execute() or die $dbh->errstr;
while ( my $ref = $sth->fetchrow_hashr ef() ) {
print $ref ->{
'bug_id', 'assigned_to', 'bug_file_loc', 'bug_severity',
'bug_status', 'creation_ts', 'delta_ts', 'short_desc',
'op_sys', 'priority', 'product_id', 'rep_plarform',
'version', 'component_id', 'resolution', 'target_milesto ne',
'status_whitebo ard', 'votes', 'keywords', 'last_diffed',
'everconfirmed' , 'reporter_acces sible', 'cclist_accessi ble', 'estimated_time ',
'remaining_time ', 'deadline', 'alias', 'login_name',
'name'
},
"\n";
}
# -e checks to see if the file exists
if (-e $excel_file) {
#open Excel file
my $Book = $Excel->Workbooks->Open($excel_fi le);
$exists = "true";
} else {
$Book = $Excel->Workbooks->Open($excel_fi le);
$exists = "true";
} else {
$Book = $Excel->Workbooks->Add();
$exists = "false";
}
if ( $exists eq "true" ) {
$previousSheet = $Book->ActiveSheet;
$currentSheet = $Book->Worksheets->Add();
$Book->ActiveSheet->{Name} = "Report";
} else {
$previousSheet = 0;
}
#create the spreadsheet
$excel->output();
#sort data of worksheet – ASC or DESC
$excel->sort_data( "Report.xls ", 0, "ASC" );
#add headers to 'Report'
$excel->set_headers( 'Report.xls', [qw/Bugs report/] );
#print sheet-names
print join( ", ", $excel->sheets() ), "\n";
#get the result as a string
my $spreadsheet = $excel->output_as_stri ng();
#print result into a file and handle error
$excel->output_to_file ("Report.xls ") or die $excel->errstr();
if ( $exists eq "true" ) {
$Book->Save();
} else {
$Book->SaveAs("$excel _file") or die $!;
}
$sth->finish();
$dbh->disconnect() ;
[/CODE]
Comment