Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:13:58+00:00 2026-06-10T21:13:58+00:00

I’ve got 2 methods of storing pages. The first is simple; store it in

  • 0

I’ve got 2 methods of storing pages. The first is simple; store it in a file. The second is to store it in the database which is I’m having issues with.
The whole “system” is based around an “engine” which outputs the page by injecting it into a HTML template. To put it simply: the code must be executed before it reaches the engine. Hopefully this will make a little more sense with some code.
page.class.php

...
// Page was found in the database
            $this->name = $pageVariables['name'];
            $this->requiredAuth = $pageVariables['requiredAuth'];
            if ($parsed) {
                ob_start();
                echo $pageVariables['content'];
                $this->contents = ob_get_clean();
                var_dump($this->contents);
            } else {
                $this->contents = $pageVariables['content'];
            }
...
// File exists on the system, load it
                $fileContents = file_get_contents($this->url);
                if ($parsed) {
                    ob_start();
                    include($this->url);
                    $this->contents = ob_get_clean();
var_dump($this-contents);
                    if (isset($pageName)) {
                        $this->name = $pageName;
                    }
                    if (isset($requiredAuth)) {
                        $this->requiredAuth = $requiredAuth;
                    }
                    if (isset($useEngine)) {
                        $this->useEngine = $useEngine;
                    }
                } else {
                    $this->contents = $fileContents;
                }

The if ($parsed) {...} is there so the page can be fetched un-parsed for editing purposes.
Obviously that is a cut down version, but I hope that shows enough.
If I load a page with the code

Hello World<br>
<?php echo 'Hello World'; ?>

from the database the output I get is

Hello World<br>
<?php echo 'Hello World'; ?>

however, the same code stored in a file outputs

    Hello World
    Hello World

I have tried using eval(), but that will only evaluate PHP code, and fails when I include the HTML/PHP mixture.
Maybe there’s a better way of going about this (storing it, executing etc), but this is the issue as I currently see it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:14:00+00:00Added an answer on June 10, 2026 at 9:14 pm

    You could use PHP’s eval to run code stored on a database.

    $code = get_code_from_db();
    eval($code); // will evaluate (run) code stored in $code variable
    

    Careful though. eval is a function that needs to be treated carefully. It could be the source of bugs, security holes, you name it, if you don’t think about the implications of the stored code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group
I have a reasonable size flat file database of text documents mostly saved in
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.