Gossamer Forum
Home : General : Perl Programming :

Re: [SimonTOZ] writing to a file or template

Quote Reply
Re: [SimonTOZ] writing to a file or template In reply to
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;
Subject Author Views Date
Thread writing to a file or template SimonTOZ 6222 Mar 4, 2004, 4:40 PM
Thread Re: [SimonTOZ] writing to a file or template
SimonTOZ 6062 Mar 5, 2004, 4:24 AM
Thread Re: [SimonTOZ] writing to a file or template
yogi 6061 Mar 5, 2004, 4:39 AM
Thread Re: [yogi] writing to a file or template
SimonTOZ 6061 Mar 5, 2004, 6:10 AM
Post Re: [SimonTOZ] writing to a file or template
SimonTOZ 6047 Mar 7, 2004, 2:41 AM