Code:
use strict; use DBI;
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Template;
my $query = CGI->new();
my $db_server = "localhost";
my $db_user = "videodb";
my $db_password = "inmos32";
my $db_database = "VideoDB";
my $dbh = DBI->connect("dbi:mysql:$db_database:$db_server",$db_user,$db_password) || die("Can't connect");
## Define your query and return the data in a format that
## you can easily stick into a template
my $SELECT = "SELECT title, Mediatype
FROM videodata
WHERE Mediatype <> '50'
ORDER BY title";
my $sth = $dbh->prepare($SELECT);
$sth->execute();
my ($title,$MediaType);
$sth->bind_columns(($title,$MediaType));
my @rows;
while ($sth->fetch) {
push @rows, { title => $title,
MediaType => $MediaType,
};
}
##Define Your Template
my $tmpl = HTML::Template->new( filename => "movies.tmpl");
## Feed the information you got from the query (@rows) into your template
$tmpl->param(rows => @rows);
## Output the html content header
print $query->header( -type => 'text/html');
## Print the template
print $tmpl_hdr->output;
This is where I am now but give the error
[Fri Mar 5 21:52:47 2004] logic.pl: Global symbol "$tmpl_hdr" requires explicit package name at logic.pl line 55.
Here is the line 54/55
## Print the template
print $tmpl_hdr->output;