Hello,

I have 2 scripts below, where DBI is used in the former and DBI and CGI is 
used in the latter.  The first script connects fine via command line, and 
the latter fails to connect, but using the same DBI code from the 
former.  I'm puzzled and RTFM before deciding to send this email.  Can 
anyone shed any light on why my script fails to connect when using CGI.pm?

Thanks,

Jonathan Gines
Sr. Software Engineer


#---------------------------------------------------------------------------------------------------------------------------------
# DBI script that connects fine via command line

#!/usr/local/bin/perl5.004
use strict;
use DBI;
# DBI stuff for testing!
#
my $login = "mylogin";
my $passwd = "mypass";
my $dbname = "mydb";
my $dbserver = "mydbserver";
my $dbh;

eval
{
        $dbh = DBI->connect("dbi:Sybase:server=$dbserver",
                $login,
                $passwd,
                { RaiseError => 1}
                );
};

if ( $@ )
{
print "DBI->connect() BOMBED!\tserver=$dbserver, db=$dbname\n";
}
else
{
print "DBI->connect() PASSED!\tserver=$dbserver, db=$dbname\n";   # this 
displays via command line
# DBI->trace(2);
}





#---------------------------------------------------------------------------------------------------------------------------------
# CGI script that "bombs", but using same DBI code that connects fine via 
command line

#!/usr/local/bin/perl5.004 -wc
use strict;
use CGI;
use DBI;

# DBI stuff for testing!
#
my $login = "mylogin";
my $passwd = "mypass";
my $dbname = "mydb";
my $dbserver = "mydbserver";
my $dbh;

my $cgio = new CGI();
print $cgio->header;
print $cgio->start_html("A CGI/DBI Test Page");
print <<END;
<H1> TIS CGI/DBI Test Page!</H1>
END


eval
{
        $dbh = DBI->connect("dbi:Sybase:server=$dbserver",
                $login,
                $passwd,
                { RaiseError => 1}
                );
};

if ( $@ )
{
        print $cgio->h2("DBI->connect() BOMBED!\tserver=$dbserver, 
db=$dbname");  # this displays, but why ... ???
}
else
{
        print $cgio->h2("DBI->connect() PASSED!\tserver=$dbserver, db=$dbname");
}

print $cgio->end_html;

Reply via email to