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 misconfiguration 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: -
#!/usr/bin/perl -W
-
use DBI;
-
use DBD::mysql;
-
use strict;
-
use File::Copy;
-
use File::Path;
-
use File::Basename;
-
use Spreadsheet::WriteExcel::Big;
-
use Data::Dumper;
-
-
my $worksheet = ['Report.xls'];
-
my $dbh = DBI->connect( "DBI:mysql:dbname=bugs:localhost", "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_milestone, b.status_whiteboard, b.votes,
-
b.keywords, b.last_diffed, b.everconfirmed, b.reporter_accessible,
-
b.cclist_accessible, b.estimated_time, b.remaining_time, b.deadline,
-
b.alias, pf.login_name, pd.name
-
FROM bugs b, profiles pf, products pd
-
WHERE bugs.assigned_to = profiles.user_id
-
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_hashref() ) {
-
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_milestone',
-
'status_whiteboard', 'votes', 'keywords', 'last_diffed',
-
'everconfirmed', 'reporter_accessible', 'cclist_accessible', '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_file);
-
$exists = "true";
-
-
} else {
-
$Book = $Excel->Workbooks->Open($excel_file);
-
$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_string();
-
-
#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();
-
5 5067
Hello Sport Girl,
Your code, as you originally posted it, contained a lot of unrecognizable characters. I'm guessing that they may be unicode or some other special character set, and that is leading to problems with running your script on the server. I suspect that the problem is either in the editor that you're using or the method in which you're transferring the file to your web server.
I've translated all the special character to their likely intended character in your above post. I've also run your code through Perl Tidy in order to clean up your formatting. You may now notice an error in your code where you have two "else" statements.
Anyway, I suggust that you figure out what is causing your character set issue before trying to do anything else. That is likely leading to problems throughout your code base, not just with this one script.
- Miller
Hi Miller, thank u very much 4 trying to helping me. I appreciate it very much.
In fact i have done what you have told me and changed the character set to ASCII in my local machine where i am supposed to do the testing but the error 500 Internal Server Error is still persisting.
I don't know if the fact is that i am not given permissions or priveleges to change in the configuration as a trainee, so they do not take effects or it's just i can't test my new code for security reasons. I have talked to my consultant about it but....
Anyway i'll post the new code , the error on the internet page is: Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
and on unix when trying to do ./scriptname.cgi is:
Unrecognized character \x93 at ./scriptname.cgi line 11.
I have done under unix "Setup- file transfer" and the following message appears:
Unable to transfer file: Host does not respond- Could not connect.
But I am logged in in unix with a username and password(i am using Reflection - Host-Unix and Digital) and i am connected in MySQL to the database( i am using Reflection - Reflection X) and i am connected to the FTP in a email address( i am using Reflection - FTP Client). I checked the ASCII character set in the Unix and FTP windows.
So could it be security or configuration reasons or what else should i do? -
-
#!/usr/bin/perl -W
-
use DBI;
-
use DBD::mysql;
-
use strict;
-
use File::Copy;
-
use File::Path;
-
use File::Basename;
-
use Spreadsheet::WriteExcel::Big;
-
use Data::Dumper;
-
my $worksheet = ['Report.xls'];
-
my $dbh = DBI->connect(DBI:mysql:dbname=bugs:localhost, 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_milestone, b.status_whiteboard, b.votes, b.keywords, b.last_diffed,
-
b.everconfirmed, b.reporter_accessible, b.cclist_accessible, b.estimated_time, b.remaining_time, b.deadline, b.alias, pf.login_name, pd.name
-
FROM bugs b, profiles pf, products pd
-
WHERE bugs.assigned_to = profiles.user_id
-
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_hashref()) {
-
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_milestone', 'status_whiteboard', 'votes',
-
'keywords', 'last_diffed', 'everconfirmed', 'reporter_accessible', 'cclist_accessible', '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_file);
-
$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_string();
-
#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();
-
-
Hi everybody, just want to say that i have resolved the problem of the character set but i have syntax errors:
can somebody help me how can i rerieve data from multilple database tables cause my query syntax is wrong: i need to retrieve data from the tables bugs, profiles and products from the database bugs.
Please can somebody help, i really need it? -
-
#!/usr/bin/perl -W
-
use DBI;
-
use DBD::mysql;
-
use strict;
-
use File::Copy;
-
use File::Path;
-
use File::Basename;
-
use Spreadsheet::WriteExcel::Big;
-
use Data::Dumper;
-
my $worksheet = ['Report.xls'];
-
my $dbh = DBI->connect("dbi:mysql:database=bugs;host=localhost") or die "Connection Error";
-
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_milestone, b.status_whiteboard, b.votes, b.keywords, b.last_diffed,
-
b.everconfirmed, b.reporter_accessible, b.cclist_accessible, b.estimated_time, b.remaining_time, b.deadline, b.alias, pf.login_name, pd.name
-
FROM bugs b, profiles pf, products pd
-
WHERE bugs.assigned_to = profiles.user_id
-
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_hashref()) {
-
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_milestone', 'status_whiteboard', 'votes',
-
'keywords', 'last_diffed', 'everconfirmed', 'reporter_accessible', 'cclist_accessible', 'estimated_time', 'remaining_time', 'deadline', 'alias', 'login_name', 'name'}, "\n";
-
}
-
if (-e $excel_file)
-
{
-
#open Excel file
-
my $Book = Workbooks->Open($excel_file);
-
$exists="true";
-
}else{
-
$Book =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_file -> 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/]);
-
#get the result as a string
-
my $spreadsheet = $excel_file -> output_as_string();
-
#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();
-
-
Unfortunately, I don't have tons of experience with DBI or SQL so I would have to look into your question. But, I did want to add this, instead of using the "-W" or "-w" switch to the shebang line, you should really use the "use warnings;" pragma instead. Just standard best practice is all.
Regards,
Jeff
Hi Jeff,
thank u for ur cooperation .I appreciate it very much.
Actually i have made a step in syntax errors but still there is something to do:
in fact i can't get the data retrieved from the bugs, products and profiles tables written in the excel sheet file.
How can i get the data retreived written to the excel sheet unless from the table bugs?
I'll give details:
the database name is bugs
the fields in the table bugs are:
bug_id
bug_file_loc
$bug_severity
bug_status
creation_ts
delta_ts
short_desc
op_sys
priority
rep_platform
version
component_id
resolution
target_milestone
status_whiteboard
votes
keywords
lastdiffed
everconfirmed
reporter_accessible
cclist_accessible
estimated_time
remaining_time
deadline
my $alias
The field in the profiles table to be retrieved: login_name
The field in the products table to be retreived is : name
Can u give me a hand with this one? -
-
#!/usr/bin/perl
-
use strict;
-
use warnings;
-
use DBI;
-
use DBD::mysql;
-
use lib qw(.);
-
use Bugzilla;
-
use Bugzilla::Bug;
-
use Bugzilla::Util;
-
use Bugzilla::Constants;
-
use Time::Local;
-
use Spreadsheet::WriteExcel;
-
-
-
my $dbh = DBI->connect('DBI:mysql:database=bugs;host=localhost', 'jinny', 'jinny') or die "Connection Error";
-
-
my $Excelfile = "/tmp/Report.xls";
-
-
#create a new instance
-
my $excel = Spreadsheet::WriteExcel->new("$Excelfile");
-
my $worksheet = $excel->addworksheet("Bugs Report");
-
my $now = localtime time;
-
$worksheet->write(0, 0, "Report generated on :$now" );
-
-
my $stmt = "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_platform, b.version, b.component_id, b.resolution, b.target_milestone, b.status_whiteboard, b.votes, b.keywords, b.lastdiffed,
-
b.everconfirmed, b.reporter_accessible, b.cclist_accessible, b.estimated_time, b.remaining_time, b.deadline, b.alias, pf.login_name, pd.name
-
FROM bugs b, profiles pf, products pd
-
ORDER BY bug_id";
-
-
-
my $sth = $dbh->prepare($stmt);
-
my @data;
-
-
$sth->execute() or die $dbh->errstr;
-
-
while ( @data = $sth->fetchrow_array()){
-
my $bug_id = $data[1];
-
my $bug_file_loc = $data[2];
-
my $bug_severity = $data[3];
-
my $bug_status = $data[4];
-
my $creation_ts = $data[5];
-
my $delta_ts = $data[6];
-
my $short_desc = $data[7];
-
my $op_sys = $data[8];
-
my $priority = $data[9];
-
my $rep_platform = $data[10];
-
my $version = $data[11];
-
my $component_id = $data[12];
-
my $resolution = $data[13];
-
my $target_milestone = $data[14];
-
my $status_whiteboard = $data[15];
-
my $votes = $data[16];
-
my $keywords = $data[17];
-
my $lastdiffed = $data[18];
-
my $everconfirmed = $data[19];
-
my $reporter_accessible = $data[20];
-
my $cclist_accessible = $data[21];
-
my $estimated_time = $data[22];
-
my $remaining_time= $data[23];
-
my $deadline = $data[24];
-
my $alias= $data[25];
-
my $login_name = $data[26];
-
my $name = $data[27];
-
my $row = 0;
-
my $col = 0;
-
foreach my $stmt (@data) {
-
$worksheet->write($row++, @data);
-
last;
-
}
-
}
-
-
$sth->finish();
-
$dbh->disconnect();
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Johnny |
last post by:
I was looking for information on how to import an excel file or other
text file into a MySql database. I have done this with both access
and SQL Server and am looking for a way to do this in...
|
by: bawar |
last post by:
Hey, I can say I belong to the newbies in this subject. I own my own
website with mySQL-databases, but now I have to show one table of
those mySQL-databases in an excel worksheet. It is the...
|
by: ctkevin |
last post by:
I am an experienced Access user but recently moved an Access database
to the web for my employer.
We use a host that does not allow the use of data access pages.
Is there anyway to pre-build a...
|
by: Anne Sachleben via AccessMonster.com |
last post by:
I am using the TransferSpreadsheet function to export a query result to a
specific worksheet in an Excel file titled "report". I want the result to
be exported to the worksheet titled "facts". ...
|
by: DeniseY |
last post by:
I have an Access report that is created on the fly by the user selecting the fields to be included. The Access report comes out fine, but I want it to automatically output to an Excel spreadsheet....
|
by: nofear |
last post by:
I used to export my reports as snapshot but now I have to export them
to Excel
When I export my report to a Excel Spreadsheet the report header and
footer are not included
Only the data gets...
|
by: Sport Girl |
last post by:
Hi everybody.
I am new in PERL language and working in it since little hours, actually i am still a trainee and i need help please.
In fact, i need a script in PERL that enables me to retrieve...
|
by: Sport Girl |
last post by:
Hi everybody ,
i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet...
|
by: Master Ken |
last post by:
Hi All,
I'm very new to C# and ASP and I am asking for some help as I don't really know where to start on this project.
Some background info first
I run a report each week which outputs data...
|
by: Alan M Dunsmuir |
last post by:
A client has sent me a (Windows) Excel Spreadsheet (.xls) file
containing a block of data he wants included as a table in a MySQL
database in a (Linux-based) PHP/MySQL Web application I'm...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |