hi, I'm trying to use the eregi_replace function to find macros, such as <% main %>, or <% title %> in a template html file i have.
When I run the code, the template displays, but with no content in it. Below is the php script I'm using
<?php
$page = $HTTP_GET_VARS['page'];
if(!isset($page))
{
$category = $HTTP_GET_VARS['cat'];
if(!isset($category))
{
$category = 1;
}
include("header.htm");
include("../news/show_news.php");
include("footer.htm");
}
else
{
include("header.htm");
include("db.php");
$query = mysql_query("SELECT * FROM pages where page_id = '$page'");
$main = $query['content'];
$title = $query['title'];
$date = $query['date'];
$filename = "template.htm";
if(!$fd = fopen($filename, "r"))
{
echo "Cant open up template";
}
else {
$template = fread ($fd, filesize ($filename));
fclose ($fd);
$template = stripslashes($template);
$template = eregi_replace("<% main %>", $main, $template);
$template = eregi_replace("<% title %>", $title, $template);
$template = eregi_replace("<% date %>", $date, $template);
echo $template;
}
include("footer.htm");
}
?>
TIA for any help that can be offered 🙂