Re: [htmltmpl] Erro: You gave me an odd number of parameters to param()!
Brought to you by:
samtregar
From: Clifton R. <cli...@ti...> - 2004-09-10 18:16:00
|
On Fri, Sep 10, 2004 at 12:45:43PM -0500, Brad Cathey wrote: > Fellow H::Ters, > > Never got this error before. > > "HTML::Template->param() : You gave me an odd number of parameters to > param()!" In my experience this usually means that there has been an unintended type conversion, e.g. an intended hash has been collapsed to a list in a parameter reference somewhere, or a list to a series of parameters. > The only thing I can think of is that my AoH is wrong but Data::Dumper > shows: > > $VAR1 = [ { > 'id' => '6', > 'teaser' => 'Domestic violence has been called a serious health crisis.', > 'title' => 'Battered and Broken', > 'number' => '214' } ]; > > Ideas?? > > Thanks in advance, Brad > > > -------------------------------------------- > Here's my Perl (and yes, Data::Dumper shows all variables have values): > > for my $i ( 0 .. $#ids ) { > $stmt = "SELECT id,title,teaser,number FROM shows WHERE id = '$ids[$i]' > ORDER BY number"; > &execute_it( $stmt ); #db operations to grab all matches > > push @$allshows, $sth->fetchall_arrayref({}); > } > > $template = HTML::Template->new(filename => 'showslisting.tmpl', > die_on_bad_params => 0); > > $template -> param(pagetitle => "Search Results", > showlist => @$allshows); Bingo. This passes the (list) contents of the thingy $allshows points to as individual parameters to param(), rather than passing the reference to the list. You want to specify the parameter as simply $allshows. -- Clifton -- Clifton Royston -- cli...@ti... Tiki Technologies Lead Programmer/Software Architect Did you ever fly a kite in bed? Did you ever walk with ten cats on your head? Did you ever milk this kind of cow? Well we can do it. We know how. If you never did, you should. These things are fun, and fun is good. -- Dr. Seuss |