#!perl use CGI; use CGI::Carp qw(fatalsToBrowser); use DBI; use CGI::Carp::DebugScreen ( engine => 'TT', debug => 1, lines => 5, modules => 1, environment => 1, raw_error => 1, overload => 1, ); my $query = new CGI; print $query->header; my $db = 'nutrientsdb'; my $hostname = '192.168.2.24'; my $user = 'rejbyers'; my $dbpwd = 'xxxxxxxxxxx'; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$hostname",$user,$dbpwd,{RaiseError => 1}) or die "Failed to connect to the DB.\n"; my $title = 'My CGI Script'; &print_html_header($title); &print_body; &print_end; exit(0); sub print_html_header { print $query->start_html(shift); } sub print_end { print $query->end_html; } sub print_body { my $sql = 'SELECT * FROM FD_GROUP'; my $sth = $dbh->prepare($sql); $sth->execute; print ''; while (my $aref = $sth->fetchrow_arrayref) { my ($code,$desc) = @$aref; print ""; } print '
$code$desc
'; $sth->finish; }