|
Posted by Marcus Bointon on 10/30/05 16:56
On 30 Oct 2005, at 14:13, John Taylor-Johnston wrote:
> echo $contents;
PHP doesn't now that it's PHP - it just treats it as text. You can
tell it to run it as PHP explicitly using:
eval($contents);
Eval is usually worth avoiding, but it will do what you ask.
Your display function could be improved:
function display()
{
$file = basename($_SERVER['PHP_SELF']);
require 'connect.inc';
$sql = "SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename`
LIKE '".addslashes($file)."' LIMIT 1;";
if ($myquery = mysql_query($sql) and mysql_num_rows($myquery) > 0) {
$mydata = mysql_fetch_array($myquery, MYSQL_NUM);
return $mydata[0];
}
return false;
}
Then call it:
if ($contents = display())
eval($contents);
This should be faster and safer than your original code.
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@synchromedia.co.uk | http://www.synchromedia.co.uk
Navigation:
[Reply to this message]
|