Gossamer Forum
Home : General : Databases and SQL :

Echo or not to echo [php/sql driven backend]

Quote Reply
Echo or not to echo [php/sql driven backend]
Hi,

I just started coding a new php/mysql driven website and encountered a problem with the following code: (my index.php)

Code:

<?

session_start();

include "/php/includes/mysql.php";
include "/php/includes/error.php";

connect_database();

include "/php/includes/functions.php";

set_referer($_GET['ref']);
$referer = (!empty($_SESSION["ref"])) ? $_SESSION["ref"] : "-";

$input = $_GET['page'];
$page = get_content($input);

?>

<br>very demo html:
<br>
<title><?=$referer;?></title>
<br>Referer: <?=$referer;?>
<br>--------------------------
<br>Page: <?=$page[title];?>
<br>--------------------------
<br>Content: <?=$page[body];?>
<br>--------------------------


Basicly the code retrieves the id,title, id and body of each page from the sql-database, puts it in a array and displays it to the user. The problem is only that $page[boby] contains php-code which is not being parsed but just showed to the user dus to the 'echo' command.

How can I rewrite my script so all php-code stored in my database is processed and not showed? (I assume this is something very basic and simple, but due to the fact this is my first php-script I have to clue how to solve this problem....)

Thanks in advance,

cK
Quote Reply
Re: [cK] Echo or not to echo [php/sql driven backend] In reply to
I'm not sure. I recently saw a script that was encoded with base64, and the way they decoded it and run as PHP was;

Code:
eval(base64_decode("base64 code goes here to be decoded"))

I'm wondering if 'eval' would do this. For example;

Code:
echo eval($page[boby])

I'm not guaranteeing this will work, as it is TBO just a stab in the dark Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!