Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:03:47+00:00 2026-06-17T16:03:47+00:00

My problem is that: the outputs are different, when I run the program on

  • 0

My problem is that: the outputs are different, when I run the program on the linux machine, and on a web browser of another machine.

When I run the program on the linux machine, the output is:

Content-type: text/plain
11
22
username password

But when I put the program on an Apache Server, and access it using a browser on another machine, the output is simply:

11

It is probably because the program fails to connect to the database file. As I have set all the files to mode 777, that I do not have the permission is unlikely a reason.

Anyone know what the problem is and how to fix it?

#!/usr/bin/perl -w

use DBI;

print ("Content-type: text/plain\n\n");

print "11\n";
my $dbh = DBI->connect("dbi:SQLite:dbname=4140.db","","",{RaiseError => 1},) or die $DBI::errstr;
print "22\n";

my $sth = $dbh -> prepare("SELECT * FROM Credential");
$sth -> execute();

($usrname, $password) = $sth -> fetchrow();

$sth -> finish();
$dbh->disconnect();

print "$usrname $password\n";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:03:48+00:00Added an answer on June 17, 2026 at 4:03 pm

    The die strings are sent to STDERR and so won’t appear in the HTTP message that is sent. You can solve this several ways, one of the simplest being to write an error handler for DBI errors that prints the error message to STDOUT.

    You should also always use strict and use warnings. That way Perl will highlight many simple errors that you could otherwise easily overlook. use warnings is far superior to -w on the command line.

    Take a look at this code as an example. Note that if you enable RaiseError as well as providing an error handler then DBI will raise an exception only if your error handler returns a false value.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use DBI;
    
    print ("Content-type: text/plain\n\n");
    
    print "11\n";
    
    my $dbh = DBI->connect('dbi:SQLite:dbname=4140.db','','',
        {RaiseError => 1, PrintError => 0, HandleError => \&handle_error});
    
    print "22\n";
    
    my $sth = $dbh->prepare('SELECT * FROM Credential');
    $sth->execute;
    
    my ($usrname, $password) = $sth -> fetchrow();
    
    print "$usrname $password\n";
    
    sub handle_error {
      my ($msg, $dbh, $rv) = @_;
      print "DB Error: $msg\n";
      0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The output of my font program is skewed. I'm pretty sure that the problem
We've run into a thorny problem. We are writing a c++ program that receives
I have a problem that output string must be utf8-formatted, I am writing currently
The problem is that I want to output Mathematica compatible floating point numbers. The
I'm currently having a problem with some Socket stuff. The output that I want
Problem I have some pages that need dynamic data from website to generate output
The Problem I've been trying to write a program that logs uncaught exceptions and
I am writing a script that calls another java program, to perform some tasks.
I wrote a script to run a command-line program with different input arguments and
Here is the situation: I have to create a program that would input another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.