Announcement

Collapse
No announcement yet.

eval help... PLEASE!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • eval help... PLEASE!

    Ok, what i'm trying to do here is set it so in a string "$hello" displays something else... Here is what i have...
    PHP Code:
    eval("\$hello = \"".get_template("test")."\";"); 
    PHP Code:
    [color=black]print(get_template('main'));[/color]
    [
    color=black]print("$hello");
    [/
    color

    and here is the get_template function...
    PHP Code:
    function get_template($template) { 
    PHP Code:
    [color=black$fetch_template_query "SELECT template_content FROM template WHERE template_name = '".$template."' LIMIT 1";
     
    $fetch_template_run mysql_query($fetch_template_query);
     
    $fetch_template mysql_fetch_array($fetch_template_run);[/color]
    [
    color=black$template $fetch_template['template_content'];[/color]
    [
    color=black$template stripslashes($template);[/color]
    [
    color=black] return $template;
    }
    [/
    color

    As you can see, i eval "$hello" to print the template "test" which is in the database... when i do print("$hello"); it works perfectly fine... however, if i have "$hello" among other text in a database template, it will simply display as "$hello"... There must be something i'm missing with eval and such... As in vB uses a method like this. So can anyone help me?
    http://www.webtrickscentral.com/images/wtcsig.jpg

  • #2
    In PHP you cant call a function and then have </font> in there. You have to echo or return it like $templatebits .= "</font>";... you should be getting a lot of parse errors the way it is written right now.

    Put all of the <font tags in a HTML template how you want the output displayed. Then return that template using mysql_query && mysql_fetch_array. You can then print() what is returned from get_template() in a PHP file.

    Comment


    • #3
      I think the <font> tags are being added by the WYSIWYG editor

      Comment


      • #4
        yea i didn't have those font tags there errr....

        well i figured it out... i had to eval the get_template function, (assigning it to a variable), then i created a new function that echoed the database template, and stripped the slashes from it.. thanx for the help!
        http://www.webtrickscentral.com/images/wtcsig.jpg

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X