This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: RE: cgi-perl example
From: Ilya Sterin <ideas_pc@usa.com>
Date: Fri, 9 Jun 2000 09:25:11 -0400 (EDT)
"wap@asl" <wap@applitechsolution.com> wrote:
> Does anyone have a small cgi-perl script using DBD::ODBC???
>
> Please send it to me so that I can test it & work ahead.
>
> I am using NT 4 with Active Perl 5.6 with DBI & DBD::ODBC installed.
Try something like this:
substitute dsnname with your own dsn name. If there is no user name or
password, just use empty quotes ""
#!/usr/local/bin/perl -w
use CGI;
use DBI;
$input = new CGI;
$input->start_html();
#begin your html tags here
$dbh = DBI->connect(DBI:ODBC:dsnname, "username", "password", {RaiseError =>
1});
$stmt = "select this from that";
$query = $dbh->quote($stmt);
$sth = $dbh->prepare($query);
$sth->execute();
while((@result) = $sth->fetchrow_array())) {
#assign variable here for as many rows as you want to display
$foo = @result[0];
$foo2 = @result[1];
print "$foo $foo2<br>";
}
#end your html tags here
$input->end_html();
===