Hello,

I am experiencing a little trouble using the class FastTemplate.

I've worked up a few php pages using this class for printing out the html. I've got a local server at home: Apache + PHP + MySQL.

The program works fine at home. But when I upload it to my Internet server, it works only every 4 / 5 times. The server gives out the following error message:

<i>
Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 213

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 199

Warning: Invalid content of {} in your script on line 213
ERROR: Nothing parsed, nothing printed
</i>

and I need to reload the page a few times before it works.

The problem seems to appear when I parse and assign the templates. I have tried to slow the program down using php (i thought the server was slow and that it didn't have enough time to assign before parsing) but that didn't help.

Here is the code:

<i>
include ("class.FastTemplate.php3");
include ("db.php3");

    $tpl = 0;

    $tpl= new FastTemplate("./view_templates");
    $tpl->define(array(
                    skeleton => "page_skeleton.tpl",
                    comment => "comment.tpl")
                    );
    $tpl->assign("PAGETITLE", "forum");
    $tpl->assign("PAGESTYLE", "style");

    $db = connect_db();

    $query = "select id, father_id, subject, email, body, posttime from comment where id=$id;";

    $result = mysql_query ($query, $db);
    $row = 0;

    $data = mysql_fetch_object ($result);

    $tpl->assign("SUBJECT", $data->subject);
    $tpl->assign("TIMESTAMP", $data->posttime);
    $tpl->assign("EMAIL", $data->email);
    $tpl->assign("BODY", $data->body);
    $tpl->assign("REPLY", "new.php3?father=$data->id");
    $tpl->parse("PAGECONTENT", "comment");
    $tpl->parse("MAIN", "skeleton");

    $tpl->FastPrint();


    exit;

</i>

Any idea?

Thanks
Thierry

    22 days later

    Thierry,

    I also faced this problem too: the same script worked on my development server, running Slack 7.0 + Apache + PHP3 + PHP4 with --enable-versioning), but on my server (running just PHP3), I got the very same error.

    The solution I have found for now is changing the following lines in class.FastTemplate.php3:

    from:
    199: $template = ereg_replace("{" . $key . "}","$val","$template");
    200: //$template = str_replace("{$key}","$val","$template");

    to:
    199: //$template = ereg_replace("{" . $key . "}","$val","$template");
    200: $template = str_replace("{$key}","$val","$template");

    and addded commented out the lines 204-225, which removes all undefined tags or complains about undefined tags. I suppose that when you'e on a production enviroment, these undefined variables should not exist.

    This should workout for now, but these errors are very annoying!

      2 months later

      I think the problem is that ereg() and ereg_replace() assign a special meaning to the braces in the search pattern - as in "{Content}".

      I fixed this by escaping the braces in the first argument to ereg and ereg_replace - so:

      ereg_replace('{something}', ...

      became

      ereg_replace{'{something}');

      More specifically - in my copy of class.FastTemplate.php I changed line 201 from:

          $key = '{'."$key".'}';

      to
      $key = '{'."$key".'}';

      and line 216 went from:

      if (ereg("({[A-Z0-9_]+})",$template))

      to

      if (ereg("({[A-Z0-9_]+})",$template))

      class.FastTemplate.php works very nicely now, so I can finally get down to USING it.

        2 months later

        Thank the Gods I found this thread - this had been driving me nuts for hours!

          15 days later

          Yes. Thank you!

          Its a nice class. The guys who wrote it to a pretty crappy at keeping it up to date. I know I was about ready to rip my damn hair out. May the computer gods look down kindly on you!

          Thanks!

          Matt

            5 months later

            AAARG!! I had the EXACT SAME PROBLEM for the last three weeks, but after looking and looking for answers I found out from reading:

            http://msdn.microsoft.com/scripting/jscript/doc/jsgrpregexpsyntax.htm

            that the curly braces have special meaning to them. I was outraged that none of the creators of fast template mentioned this bug, but after that I had no more fast template problems!!

            If only i read this forum 3 weeks ago!! And to think i almost trashed fast template and almost went back to the old non-template form.

              2 months later

              Apparently ereg_replace has altered it's form !

              Luckily I got to this thread right away !

              Thanx guys.

                12 days later

                I am still am having the problem. Even after I escaped the curlies. and str_replace doesn't work for the part in the (!$STRICT) block because it is an ereg statement.

                  a month later

                  I had developed a site on IIS4 for Win2K.
                  Then had to move it over to Linux Apache.

                  Then I got this problem..
                  I played with magic quotes, and all sorts of other silly stuff.

                  But when I just changed line 199(varies from version to version of the file)

                  from :

                  $template = ereg_replace("{$key}","$val","$template");

                  to:

                  $template = ereg_replace("{" . $key . "}",$val,$template);

                  Everything fell into place.

                  Hope that can help anyone else 🙂

                  thierry wrote:

                  Hello,

                  I am experiencing a little trouble using the class FastTemplate.

                  I've worked up a few php pages using this class for printing out the html. I've got a local server at home: Apache + PHP + MySQL.

                  The program works fine at home. But when I upload it to my Internet server, it works only every 4 / 5 times. The server gives out the following error message:

                  <i>
                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line 213

                  Warning: Invalid content of {} in your script on line 199

                  Warning: Invalid content of {} in your script on line....

                    2 months later

                    Thanks to Johnathan!... obviously the complete solution to my problem was the last message =).

                    But I was another problem with Fast Template because class.FastTemplate that gaves me another error:

                    Warning: Invalid content of {} in /var/www/html/felix/class.FastTemplate.php3 on line 214

                    ...

                    I resolved that problem just using the Johnathan way...

                    Changing this line:

                    if (ereg("{[A-Z0-9_]+})",$template))

                    with this one:

                    if (ereg("({"."[A-Z0-9_]+"."})",$template))

                    [Please, forgive my poor enlgish ;-\

                    Félix

                      3 months later

                      I fixed mine using felix's solution by fixing lines 174,199, 208 and 213 (214 on Felix's) to look something like:

                      174: if (ereg("({"."[A-Z0-9_]+"."})",$Line,$unknown))

                      199: $template = ereg_replace("{"."$key"."}","$val","$template");

                      208: $template = ereg_replace("{"."([A-Z0-9_]+)"."}","",$template);

                      213: $template = ereg_replace("{"."$key"."}","$val","$template");

                      when i fixed line 213 first (first warning), i thought it was fixed because it can parse but there were excess {}s in the output. To be safe, I looked for all the ereg() and ereg_replace() calls and made my fix.

                      No problems so far. Thank you all.

                      Clint

                        Write a Reply...