Hi All,

I have been using html::template for a short whle with succes now, but here 
is something I don't understand.
I have several scripts which are all very similar working perfectly fine, 
but now I have a 'demo' copy on a public server.
Most of it workds fine, but when I query the database (PostgreSQL), my 
scripts come back with an error.

I have put the error, scrpt and template below.
Can anyone help please?

Thanks!

Oscar

 > perl itemtype_list.cgi
Content-Type: text/html; charset=ISO-8859-1

HTML::Template->output() : fatal error in loop output : Can't coerce array 
into hash at /usr/lib/perl5/site_perl/5.6.1/HTML/Template.pm line 2726.
  at itemtype_list.cgi line 64

The scipt is mentioned below:
#!/usr/bin/perl

######################################################################
# SQL-Trading
# Copyright (c) 2001
#
#  Author: Oscar Buijten
#   Email: [EMAIL PROTECTED]
#     Web: http://sql-trading.elbie.com
#
#  Contributors:
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#######################################################################
#
# CHANGE LOG:
#   OAB. 02-12-2001  Created
#
#######################################################################
#
# This script lists the itemtypes available
#
#######################################################################

use DBI;
use HTML::Template;
use CGI;
require '../pg_tools.lib';

&sql_connect;
my $CGI = new CGI;

# this will be explained after the END statement
my %attr = ( dbi_fetchall_arrayref_attr => {});
# grab the stuff from the database
my $rows = $dbh->selectall_arrayref("
     SELECT *
     FROM producttypes
     ORDER BY producttype
", \%attr);

# prepare the template and substitute the values
my $template = HTML::Template->new(path => '../templates',
                                         filename => 'itemtype_list.tmpl',
                                         associate => $CGI,
                                         loop_context_vars => 1,
                                          );
$template->param(ITEMLIST => $rows);

# print the goods
print $CGI->header;  # Line 64
print $template->output;
$dbh->disconnect;


__END__

The template:

<HTML>
<HEAD>
<link REL="STYLESHEET" HREF="../stylesheet.css" TYPE="TEXT/CSS">
</head>
<body class="right">
<center><br>
|&nbsp;<a href="../right.html" target="right">Close Frame</a>&nbsp;|&nbsp;
<a href="itemtype_add.cgi" target="main">Add Item Type</a>&nbsp;|<br><br>
   <table cellspacing="0" cellpadding="0" class="table">
   <td>
      <table width="100%">
   <TMPL_LOOP NAME="ITEMLIST">
      <tr>
      <TMPL_IF NAME="__FIRST__">
      <th class="header">ITEM TYPES</th></tr>
      </TMPL_IF>
      <TMPL_IF NAME="__ODD__">
           <td class="tablerowodd"><a 
href="itemtype_edit.cgi?producttypenumber=<TMPL_VAR 
NAME="PRODUCTTYPENUMBER">&producttype=<TMPL_VAR NAME="PRODUCTTYPE">" 
target="main"><TMPL_VAR NAME="PRODUCTTYPE"></a></td>
      <TMPL_ELSE>
           <td class="tableroweven"><a 
href="itemtype_edit.cgi?producttypenumber=<TMPL_VAR 
NAME="PRODUCTTYPENUMBER">&producttype=<TMPL_VAR NAME="PRODUCTTYPE">" 
target="main"><TMPL_VAR NAME="PRODUCTTYPE"></a></td>
      </TMPL_IF>
      </tr>
   </TMPL_LOOP>
      </table>
    </td>
    </table>
</center>
</body>
</HTML>

__________________________________________________________________

Oscar Buijten

Tel: +33.4.67.57.97.45
Fax: +33.4.67.57.97.46
GSM: +33.6.20.84.15.22

Email: [EMAIL PROTECTED]

Web: www.elbie.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to