Hey all,
I have this message board I am working on (http://dhoss.perlmonk.org/ethereal) that uses HTML::Template and DBI to generate the pages for my site.
My dillemma:
I am retrieving the sql from a sub called selectMsgFromDb that selects the proper sql query from a configuration module that has all the sql queries in a hash (Security problems???) and executes it, returning the data from the db. It does that just fine, sorta, but it returns 14 (the number of threads in my messages table) EVERY TIME instead of the $sth->{hash_value} values.
Any ideas? Here is the source:
# select sub sub selectMsgFromDb { my ($self, %params) = @_; $self->checkRequiredParams(%params); my $sth = $dbh->prepare( $cfg->{retrieve_from_sql}->{msg} ); $sth->execute( ); my @msgs; while ( my $thread = $sth->fetchrow_hashref() ){ my (@data) = q[$thread->{id}, $thread->{name}, $thread->{date}, $thread->{subj}, $thread->{day_rate}, $thread->{msg}]; push @msgs, @data; } return @msgs; # code for returning the page my ($content); push @{$content}, $params{-content}; $template->param( MAIN_CONTENT=>$content ); return $template->output; # hash for sql my %sql = ( msg =>'SELECT id, name, date, subj, day_rate, msg FROM mes +sages ORDER BY DATE DESC', reply =>'SELECT id, name, date, subj, day_rate, msg FROM m +essages ORDER BY DATE DESC', insert =>'INSERT INTO ethereal VALUES(0, ?, ?, ?, NOW(), ? +)' );

Thanks in advance,

dhoss

"and I wonder, when I sing along with you if everything could ever feel this real forever? if anything could ever be this good again? the only thing I'll ever ask of you, you've gotta promise not to stop when I say 'when'", she sang

In reply to HTML::Template problems by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.