Re: php not activated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux