Hi. I have the following function:
function DisplayTemplate($templatefile, $vars) {
//$line=implode(file($templatefile), "");
$line = "";
$line=implode("", file($templatefile));
eval("global $vars;");
$vars = str_replace(",","",$vars);
$var_list = explode("\$",$vars);
for($i=0; $i<count($var_list); $i++) {
[COLOR=red]$line = str_replace("<%$var_list[$i]%>",${$var_list[$i]},$line);[/COLOR]
}
if (preg_match ("/<%top10links%>/","$line")) {
$line = str_replace("<%top10links%>",top10links(),$line); //Add the top10
}
if (preg_match ("/<%banner_rotator%>/","$line")) {
$line = str_replace("<%banner_rotator%>",banner_rotate(),$line); //Banner Rotator
}
print $line;
}
This function is included in a common file and is called as follows per script.
DisplayTemplate($template_path."header.html","\$var1,\$var2");
echo($test_page);
DisplayTemplate($template_path."footer.html","\$var1");
The function displays the page as you've noticed. The problem is on the banner_rotator().
The banner_rotator() function rotates a set of banners randomly selected from a db, one at a time.
On local machines it works ok.
However when on a web host, it displays me only the first banner in the db. Always the same.
The banner function is ok with no problems. The query when run from a GUI it returns random results.
It also returns me errors in the log_file about undefined variable in the red line. It doesn't tell me what variable.
Can somone figure out what's wrong?
Thanks
John