I have decided to completely convert my Web site to be MySQL driven, for many reasons. My problem is this.
I have two things stored for each page, the PHP that sets the value of a variable, $output, and the page template which puts HTML around the $output variable's contents.
Since both of these are stored in MySQL, I use eval() for PHP, which works fine. However, when I try to print() the template value from the MySQL, $output is not parsed.
For example:
PHP code (stored in MySQL)
$output="foo";
$output.="bar";
HTML template (stored in MySQL)
<html>
<body>
$output
</body>
</html>
File (stored on the server)
<?php
$link = mysql_connect("localhost", "username", "password")
or die("Could not connect : <pre>" . mysql_error() . "</pre>");
mysql_select_db("redhelix_site") or die("Could not select database");
$table="table1";
$query = "SELECT * FROM ".$table;
$result = mysql_query($query) or die("Query failed : " . mysql_error());
while($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
eval($line[code=php]);
echo $line[template];
}
mysql_free_result($result);
mysql_close($link);
?>
However when the code above is executed, $content is not parsed. In fact, it doesn't show up at all. It is blank. But when I add "echo $output;" somewhere, the $output shows up fine.
Thanks in advance.