The PHP code in the database must not have opening and closing PHP tags,
just the raw PHP code.
And any HTML must be echoed.
Example:
The code in the database could look like this,
notice that there are no opening or closing PHP tags.
PHP Code:
echo "<p>Hello World.</p>";
Then your code will work.
PHP Code:
<?php
$value = $_GET['page'];
$host = "localhost";
$user = "ID";
$password = "PW";
$db_name = "DB";
$connection = mysql_connect($host, $user, $password);
$db = mysql_select_db($db_name) or die( "Couldn't select database");
$sql = "SELECT * FROM site WHERE page_id = '$value'";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ($num_rows == 0){
echo " ";
}
else {
while ($row=mysql_fetch_array($mysql_result)) {
$pagename=$row["pagename"];
$content=$row["content"];
echo "<h1>$pagename</h1>";
eval($content);
}
}
mysql_close($connection);
?>