Hello Monks,
I really need some help and I'm sure like always it's something simple, but I just cant figure it out tonight for some reason. Basically I have a very basic index.cgi file that runs 2 sql queries and should eventually send that data into the tmpl file to be looped. Problem is I apparently have an issue with 1 of my 4 values being passed to the file because the following error is triggered apon execution of index.cgi:
HTML::Template->output() : fatal error in loop output : HTML::Template : Attempt to set nonexistent parameter 'loc_value' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at /usr/lib/perl5/site_perl/5.8.3/HTML/Template.pm line 2962
at index.cgi line 17
I turned off die_on_bad_params just to see what would happen and my data from @network_data is there, but @location_data seems to be added as whitespace onto the NETWORK_DATA loop!
Here is the top part of my index.cgi script:
#!/usr/bin/perl -w
use strict;
use HTML::Template;
use DBI;
##DB CALL##
my (@network_data, @location_data) = get_data();
##Template##
my $template = HTML::Template->new(filename => 'main.tmpl');
$template->param( NETWORK_DATA => \@network_data);
$template->param( LOCATION_DATA => \@location_data);
print "Content-Type: text/html\n\n", $template->output;
I have tested the data in @network_data & @location_data and the data was there. Also when I append @location_data to @network_data the data makes it through to the webpage as well. To help visualize these LOOP's populate HTML drop downs. Here is the relavent parts of my main.tmpl file.
main.tmpl:
IP:
<select name="network" id="network">
<option value="None" selected>None</option>
<TMPL_LOOP NAME="NETWORK_DATA">
<option value="<TMPL_VAR NAME=NET_ID>"><TMPL_VAR NAME=NET_
+VALUE></option> <br>
</TMPL_LOOP>
</select>
<select name="location" id="location">
<option value="None" selected>None</option>
<TMPL_LOOP NAME="LOCATION_DATA">
<option value="<TMPL_VAR NAME=LOC_ID>"><TMPL_VAR NAME=LOC_
+VALUE></option> <br>
</TMPL_LOOP>
These loops are not within each other and I dont care whether or not they can access each other's data. I am simply trying to have essentially 2 while loops with 2 data sets that loop through and print out and for some reason LOC_VALUE is triggering an error. I've switch around so many things I can't remember any more helpful information to tell at this time.
This is how and what Im stuffing my array's:
while (my $ref = $sth->fetchrow_hashref()) {
my %row_data;
$row_data{NET_ID} = $ref->{'id'};
$row_data{NET_VALUE} = $ref->{'value'};
push(@network_data, \%row_data);
}
while (my $ref2 = $sth2->fetchrow_hashref()) {
my %row2_data;
$row2_data{LOC_ID} = $ref2->{'id'};
$row2_data{LOC_VALUE} = $ref2->{'value'};
push(@location_data, \%row2_data);
}
I REALLY appreciate any help I can get.
Thanks,
YpCat
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.