Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#120 Template Error.

closed-out-of-date
nobody
index (20)
5
2001-11-23
2001-08-07
Anonymous
No

often, upon entering the main index page. Usualy the
first time,i get the error message

'Template Error: loadfile: loadfile is not a valid
handle. Halted.'

when the page is refreshed, there isn't a problem
anymore. Would someone be so kind as to advise me as
to why this happens and what i can do to sort it out.

Kind Regards.

Discussion

  • Luis M
    Luis M
    2001-09-19

    Logged In: YES
    user_id=239796

    There seems to be a bug with the first connection, as you
    said before. I'm trying to get a connection established
    before the assignment of the first section:
    if (!$section) { section =
    getvar("site_homesection","quite"); ...

    to see if that has something to do with this bug (trial and
    error so far, i don't quite understand how the code works,
    but as I keep looking to fix this bug you mention, I get
    more and more understanding of the way the code works).

    another solution, which I think is the reason why i never
    saw this error before, is to have Apache/PHP (compiled
    statically in my case) keep a persistent connection to
    MySQL. For some reason I think this is not happening now
    (after I upgraded MySQL and PHP to 4.0.6 -- with apache
    1.3.20 -- was when this problem started happening).

    lems1@latinomixed.com

     
  • Luis M
    Luis M
    2001-09-20

    Logged In: YES
    user_id=239796

    Ok, now I'm standing on better grounds:

    Throughout the whole .class and .php3 files the default
    $site_homesection is "Home", so if for reason a connection
    to the database cannot be done and the $site_homesection was
    changed from it's default value "Home" to something else,
    when you connect the first time to the page and for whatever
    reason the connection to the db doesn't return a value for
    getvar("site_homesection") variable; you might get the
    default "Home". So, if you are like me and you replace the
    default phpSlash $site_homesection to be other name, and
    "Home" section doesn't exist, you are in serious trouble :-)
    But, that's only part of the problem the main problem with
    the loadfile() call is that in index.php
    template->set_file() is called AFTER $allstories =
    $story->getStory($ary); so, the handle 'index' doesn't exist
    yet. (I think that's true, but I'm not sure about that yet.
    Correct me if I'm wrong). I 'solved' this by moving the
    $allstories assignment and $allblocks to after the
    $template->set_file(index,"index.tpl"); call.

    another important detail, check your /etc/php.ini (or
    wherever that php.ini is) and make sure that the [Session]
    block has session.autostart set to '1'; you can make sure
    you have this setup if you check your temporary
    folder/partition where the (temporary) sessions are stored.
    After setting this to 1 in my php.ini things started to get
    better with my sessions (even though i know they should be
    stored in the database as active sessions).

    again, I don't know much about how phpSlash works, but I'm
    getting closer (I have to fix this template error/bug quick)
    . If anybody has any ideas, please keep posting here.

    For now I give up... :-)

    lems1@latinomixed.com

     
  • Luis M
    Luis M
    2001-09-20

    Logged In: YES
    user_id=239796

    SOLUTION FOUND:

    ok, I could not resist this one. So I found a simple
    solution until somebody fixes the bug somewhere else (better
    way?). Do this (read my previous posts):

    --index.php3--

    //after: $template = new Template(....
    //$template->debug = 0;
    //$template->set_file(index,"index.tpl");...
    //put this line:
    $template->file[index]="templates/index.tpl";

    /* basically the problem is because the handler 'index' is
    not set in array file of the Template class of PHPLib
    (reread if you didn't get it the first time), so when
    loadfile() call looks for that key value in the file array,
    and doesn't find it, it gives that infamous error that was
    the original reason why i'm writing all this! hopefully a
    better solution will be found later. For now, peace!

    if you want to get a simple weblogger based on PHP/MySQL
    follow this link:

    http://www.latinomixed.com/index.php3?section=Weblogger

    You could use phpSlash to keep a weblogger, but this is a
    simpler one; the code is GPL'd; it's fully customizable...
    etc... follow the link and read more about it plus check the
    screen shot...

    enjoy!

    ps. i'll be registering the project in SourceForge later... :-)
    lemsx1@hotmail.com
    lems1@latinomixed.com
    */

     
  • Luis M
    Luis M
    2001-09-22

    Logged In: YES
    user_id=239796

    Better solution!

    OK, I have to admit that I was wrong. the last solution
    didn't solve my (our?) problem, so, I opened
    phplib/template.inc file and added this to the line (310):
    ---- template.inc -----
    if (!isset($this->file[$handle])) {
    // comment out the two lines there about halting
    $this->file[index]="templates/index.tpl";
    }
    ------ end -------------

    I have to admit that I have not fully ultra test this, but
    it works! And all other sections, search, etc... pages
    seemed to work find. Now, if I could just find a way to make
    it work better...

    note: phpWeblogger project was finally born in SourceForge.
    I have not uploaded anything yet, but you can get the source
    in a compressed tarball from:
    http://www.latinomixed.com/index.php3?section=phpWeblogger
    Soon you will be able to just get it from
    http://sourceforge.net/projects/phpweblogger ... I need help
    with the extra functions that the project needs, so if
    anybody is just starting to code in PHP/C/C++ or anything
    alike and would like to have fun coding some PHP, drop me an
    email: lemsx1@hotmail.com

     
  • Luis M
    Luis M
    2001-09-22

    Logged In: YES
    user_id=239796

    At last:

    ok, it seems that getvar creates problems with PHP4. but
    that call is part of phplib. if you do not want to see the
    template error again, just get the CVS module phpslash-ft
    from the CVS repository :-)

    and of course read and make sure you know what you are doing
    before replacing any of your old files...

    it works beautifully

     
  • nathan hruby
    nathan hruby
    2001-11-23

    • status: open --> closed-out-of-date
     
  • nathan hruby
    nathan hruby
    2001-11-23

    Logged In: YES
    user_id=19736

    So.. Umm is this bug fixed?

    Closing bug as last update states that it's fixed in the -ft
    module which will shortly be the 0.65 release. If not true,
    please feel free to reopen the bug.