Using the ".=" operator only made the script die... without solving my problem.
The point of this function is to take a template from the database, look for matches from an array of color and font replacement variables in the template, do the replacements and return the formatted string. If anyone knows of a better means of accomplishing this (without using something like Smarty) in a similar manner please let me know.
function getTemplate($template, $getcomments=1)
{
GLOBAL $c;
$result = mysql_query("SELECT templatetitle,templatevalue FROM arc_template WHERE templatename='$template' AND templatetype='default'");
$array = mysql_fetch_array($result);
extract($array, EXTR_OVERWRITE);
$colorstr = getColors($c);
include($colorstr);
extract($styles);
foreach($styles as $stylename => $stylevalue) {
$templatevalue = str_replace("<$stylename>", "$stylevalue", $templatevalue);
}
if ($getcomments==1) {
return "\n<!-- start $templatetitle -->\n$templatevalue\n<!-- end $templatetitle -->\n";
} else {
return $templatevalue;
}
}
And this is how I call the function...
$pquery = mysql_query("SELECT * FROM pagebit WHERE page='$action' ORDER BY pdate");
echo '<br />';
while ($page = mysql_fetch_assoc($pquery)) {
$pagebit = getTemplate('pagebit'); //get template 'pagebit'
extract($page, EXTR_OVERWRITE);
str_replace("<pagebit_title]>", "$ptitle", $pagebit);
str_replace("<pagebit_content]>", "$pcontent", $pagebit);
echo $pagebit;
}
I also echo'd the variables that are supposed to be inserted into the template to test them and they worked so the problematic code for me in both instances is str_replace. I tried using ereg_replace and preg_replace as well but neither helped.