Majoracle
12-08-2006, 10:05 PM
I've been trying to create a template system, and ran into a problem that seems like it'd be a simple fix, but I can't seem to find the answer. I'm low on time, so I'll just you the code I have and the error rather than explaining it.
Get Template Function (works):
function fetch_template($name)
{
$get_template = "SELECT `template` FROM `templates` WHERE `name`='$name' LIMIT 1";
$get_template_res = mysql_query($get_template);
$fetch_template = mysql_fetch_array($get_template_res);
$template = $fetch_template['template'];
return $template;
}
Eval Function and Echo Output:
eval('$display = "' . fetch_template('template_name') . '";');
echo $display."\n";
PHP Error:
Parse error: syntax error, unexpected '<' in path/to/php/file(24) : eval()'d code on line 3
I'm pretty sure it's a problem with the eval function reading HTML from the template. Just can't figure out a fix.
Thanks in advance
Get Template Function (works):
function fetch_template($name)
{
$get_template = "SELECT `template` FROM `templates` WHERE `name`='$name' LIMIT 1";
$get_template_res = mysql_query($get_template);
$fetch_template = mysql_fetch_array($get_template_res);
$template = $fetch_template['template'];
return $template;
}
Eval Function and Echo Output:
eval('$display = "' . fetch_template('template_name') . '";');
echo $display."\n";
PHP Error:
Parse error: syntax error, unexpected '<' in path/to/php/file(24) : eval()'d code on line 3
I'm pretty sure it's a problem with the eval function reading HTML from the template. Just can't figure out a fix.
Thanks in advance