You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Gavin Spomer <ga...@solaris.ellensburg.com> on 2000/09/30 15:23:25 UTC
Recursion Problem
Hello all!
I've been messing around w/ embperl for about a year now and I am currently
implementing an online message board, just to see if I could do it. Everything
has been working peachy-keen until I tried to do some recursion. The main part
of my code displays message subjects, dates, etc in a table (data from a
database) and after each row calls my display_replys function. Here is a
workable version w/ the recursive call commented out:
http://www.kvic.com/messages.epl
Without the recursion, it only displays one reply to a topic. (it won't display
a reply to a reply)
If anyone wants to take a stab at my problem, you can view the code at:
http://www.kvic.com/messages.txt
When I ran this page w/ the recursive call I got into an infinite loop. My base
condition seems okay to me. I'm sure it doesn't have anything to do with the
data in the database. Anyone?
http://www.singlespeedsanonymous.com/
"People are the worst drivers in the world" -Gavin Spomer
Re: Recursion Problem
Posted by Gerald Richter <ri...@ecos.de>.
Hello all!
I cannot access your pages anymore, but a recursive request would look like
the following:
[*
# localize variables
local $sth ; # don't use my here, it doesn't work with Embperl 1.x
*]
[-
$sth = $dbh -> prepare ("SELECT * from foo where id = $param[0]") ;.
$sth -> execute ;
-]
[$while $rec = $sth -> fetch $]
[- Execute ('myself.epl', $rec -> {id}) -]
[$endwhile$]
The important pieces is the [* *] block which makes sure you get a new
local statement handle for every (recuirsive) call of the page. I use this
technic in my own pages and it works great.
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------