My script doesnt want to connect to database.
I have installed Perl on my workstation and added the DBI and DBD-ODBC and
created a DSN for my ODBC. A regular CGI script works fine but CAN'T connect
to a database.
It keeps dying at the die area where something is wrong with the connection:
$dbh = DBI->connect('DBI:ODBC:dbname','','')
This is trying to access an Access97 db on my
Windows NT workstation.
Here is the script:
#!/usr/local/bin/perl
use CGI qwall);
print header,
start_html("List"
use DBI;
$dbh = DBI->connect('DBI:ODBC:dbname','','') | | die print "ERROR HERE";
$statement = "SELECT * FROM agents";
$sth = $dbh->prepare($statement);
$sth->execute;
@headings = ("Agent ID", "First Name", "Last Name", "E-mail"
print "<center>", h2("Agent List",
"<table border>", Tr(th([@headings]));
while (@row = $sth->fetchrow_array) {
print Tr(td([@row]));
} ;
print "</table></center>", end_html;
$sth->finish;
$dbh->disconnect;
I have installed Perl on my workstation and added the DBI and DBD-ODBC and
created a DSN for my ODBC. A regular CGI script works fine but CAN'T connect
to a database.
It keeps dying at the die area where something is wrong with the connection:
$dbh = DBI->connect('DBI:ODBC:dbname','','')
This is trying to access an Access97 db on my
Windows NT workstation.
Here is the script:
#!/usr/local/bin/perl
use CGI qwall);
print header,
start_html("List"
use DBI;
$dbh = DBI->connect('DBI:ODBC:dbname','','') | | die print "ERROR HERE";
$statement = "SELECT * FROM agents";
$sth = $dbh->prepare($statement);
$sth->execute;
@headings = ("Agent ID", "First Name", "Last Name", "E-mail"
print "<center>", h2("Agent List",
"<table border>", Tr(th([@headings]));
while (@row = $sth->fetchrow_array) {
print Tr(td([@row]));
} ;
print "</table></center>", end_html;
$sth->finish;
$dbh->disconnect;