> Dear All
>
> I have a a php template script (see below). It references
> two templates,
> newuser.ihtml and select_dbout.ihtml (see below).
>
> What I am trying to do is use select_dbout.ihtml twice within
> new user.ihtml
> to give database driven select lists. It all works fine
> until I have both
>
> $templ->parse("rows", "row", true);
>
> statements when I get the following error message:
>
> Template Error: loadfile: row is not a valid handle.
> Halted.
>
> Can anyone explain why this and if it is possible to use the
> block template
> witihin the same file?
You already set the block on line 41, so the block is not there when you try
to set it on line 70. You only need to (and indeed are only able to) set the
block once - the row variable will still be there for you.
Yes, you can use the block multiple times, but you need to handle it a
little differently. In your example, put line 47's parse statement back in
and replace line 70 with
$templ->set_var("rows", "");
There is an easier way to do this though.
Make line 41:
$templ->set_block("select_dbout", "row");
(you won't be parseing select_dbout at all)
Make line 47:
$templ->parse("roles_dbOutput", "row", true);
Eliminate lines 51 and 70.
Make line 74:
$templ->parse("status_dbOutput", "row", true);
Then simple parse the newuser file.
On a side note, if you change your sql to:
"select id as key, name from roles" and
"select value as key, name from status"
then in your database loop you will only need to:
$templ->set_var($db->Record);
Layne Weathers
Ifworld Inc.
|