SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2002
    Location
    Asker, Norway
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    run php code from a database field

    i'm trying to make my own cms, but have some troubles

    I have made an option to make a page dynamic
    Then I store php code in a field called php in the database
    (only editable by me)
    And when the page is dynamic i want to run the php code instead of displaying the content in the body field

    So want something like this code:
    [PHP] if ($page[dynamic]=='true') {
    ob_start();
    $page
    PHP Code:
    ;
                       
    $content ob_get_contents();
                       echo 
    $content ;
                       } 
    But it don't work. how can i make it work

    the databasefield contain e.g. "echo $_SERVER[HTTP_USER_AGENT];"

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u have to use eval();
    cheers

  3. #3
    SitePoint Addict DA Master's Avatar
    Join Date
    Apr 2004
    Location
    /etc/php.ini
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah using the eval function is the only way, however this function is open to massive abuse if used wrong.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •