FAQ
Hello all,

Well after I finally got DBI installed on Mac OS X I made a quick test
script. I then tested it out from the terminal and debugged it. It
works! I then tried it on my Apache server, same system same database.
This time, however I get a 500 error. In the error log I see this line:

[Tue Apr 12 05:34:26 2005] [error] [client 24.238.83.11] malformed
header from script. Bad header=11, 2004, 13, Salt and Pepper :
/Library/WebServer/CGI-Executables/useDB.cgi

Here is the script I am testing:

#!/usr/bin/perl -w
use Time::localtime;
use Time::Local;
use CGI qw(:standard);
use strict;
use File::stat;
use DBI;
my $dbh =
DBI->connect("DBI:mysql:test",'myUser','myPass',{RaiseError=>1}) or
print "connecting: $DBI::errstr\n";
my $selectStm = $dbh->prepare("SELECT * FROM churchEvents WHERE
eventMonth = '11' AND eventYear = '2004'");
$selectStm->execute;
my @row;
while((@row)=$selectStm->fetchrow){
print join(", ",map{defined $_ ? $_:"(null)"}@row,"\n");
}
$selectStm->finish;
$dbh->disconnect;


Anyone know where to start looking? I have even tried re-writing the
script in case I hade a stray hidden character in the original.

Thanks,

Bruce Martin
The Martin Solution
PO Box 644
Delaware Water Gap, PA
(570) 421-0670
bruce@martinsolution.com

Search Discussions

  • Thilo Planz at Apr 12, 2005 at 9:55 am

    Well after I finally got DBI installed on Mac OS X I made a quick test
    script. I then tested it out from the terminal and debugged it. It
    works! I then tried it on my Apache server, same system same database.
    This time, however I get a 500 error. In the error log I see this
    line:

    [Tue Apr 12 05:34:26 2005] [error] [client 24.238.83.11] malformed
    header from script. Bad header=11, 2004, 13, Salt and Pepper :
    /Library/WebServer/CGI-Executables/useDB.cgi

    Actually, your script works.
    It says "11, 2004, 12, Salt and Pepper" which seems to be coming out of
    your database.

    What you need to do is print a CGI header before printing anything else:
    use CGI qw(:standard);
    use strict;
    print CGI->header;

    If you do not do this, Apache does not know what to do with the output.

    Here is a good CGI tutorial:

    http://users.easystreet.com/ovid/cgi_course/


    Cheers,

    Thilo
  • Bruce Martin at Apr 12, 2005 at 10:02 am
    Of course! I don't know what I was thinking. Thank you for your quick
    response.
    On Apr 12, 2005, at 5:54 AM, Thilo Planz wrote:

    Well after I finally got DBI installed on Mac OS X I made a quick
    test script. I then tested it out from the terminal and debugged it.
    It works! I then tried it on my Apache server, same system same
    database. This time, however I get a 500 error. In the error log I
    see this line:

    [Tue Apr 12 05:34:26 2005] [error] [client 24.238.83.11] malformed
    header from script. Bad header=11, 2004, 13, Salt and Pepper :
    /Library/WebServer/CGI-Executables/useDB.cgi

    Actually, your script works.
    It says "11, 2004, 12, Salt and Pepper" which seems to be coming out
    of your database.

    What you need to do is print a CGI header before printing anything
    else:
    use CGI qw(:standard);
    use strict;
    print CGI->header;

    If you do not do this, Apache does not know what to do with the output.

    Here is a good CGI tutorial:

    http://users.easystreet.com/ovid/cgi_course/


    Cheers,

    Thilo
    Bruce Martin
    The Martin Solution
    PO Box 644
    Delaware Water Gap, PA
    (570) 421-0670
    bruce@martinsolution.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedApr 12, '05 at 9:39a
activeApr 12, '05 at 10:02a
posts3
users2
websitedbi.perl.org

2 users in discussion

Bruce Martin: 2 posts Thilo Planz: 1 post

People

Translate

site design / logo © 2022 Grokbase