PDA

View Full Version : eval help... PLEASE!


jamslam
Wed 30th Jul '03, 1:40pm
Ok, what i'm trying to do here is set it so in a string "$hello" displays something else... Here is what i have...

eval("\$hello = \"".get_template("test")."\";");
print(get_template('main'));
print("$hello");

and here is the get_template function...

function get_template($template) {
$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);
$template = $fetch_template['template_content'];
$template = stripslashes($template);
return $template;
}

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?

WebForumDev
Wed 30th Jul '03, 5:58pm
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.

MUG
Wed 30th Jul '03, 6:20pm
I think the <font> tags are being added by the WYSIWYG editor :p

jamslam
Sun 3rd Aug '03, 11:31pm
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!