include PHP script from MyQSL database

  • Zielak69
  • Novice
  • Novice
  • No Avatar
  • Joined: 25 Jun 2008
  • Posts: 21
  • Loc: Poland
  • Status: Offline

Post December 1st, 2008, 12:38 pm

So here's the thing.
I've put my php script into a database as 'longtext' and I want it to be compiled by PHP. Right now it just shows me the script as simple non-compilated text. For example:
  1. <?
  2. // script to get a row from db with html and php script
  3. // the variable that is holding it is $f and it contains something like:
  4. // <b><? echo $a; ?></b>
  5. $a = 'hello there';
  6.  
  7. echo $f;
  8.  
  9. ?>

The output should be
  1. <b>hello there</b>


Is that possible to do? Or is there any other way of doing it?

.. or should I simply put that scripts in .php files and use include() ?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post December 1st, 2008, 12:38 pm

  • mishka
  • Novice
  • Novice
  • No Avatar
  • Joined: 28 May 2005
  • Posts: 20
  • Loc: Toronto
  • Status: Offline

Post December 1st, 2008, 12:51 pm

Oh man ... use include()...

Just the way of thinking to utilize DB engine to store scripts is unappropriated from conceptual POV ...
  • joebert
  • S.T. Manager
  • Genius
  • User avatar
  • Joined: 10 Feb 2004
  • Posts: 10999
  • Loc: Clearwater, FL
  • Status: Offline

Post December 1st, 2008, 1:39 pm

File includes/requires is the way I would go.

Something like XCache can cache the opcode for the file includes, whereas even if you use memcached to reduce the load on the database, you'ld still have to exec() the script every time.
The squeaky wheel gets the grease, but the whining wheel gets replaced.
Picksel: Ubuntu/Gnome alternative to Colorpix
  • Zielak69
  • Novice
  • Novice
  • No Avatar
  • Joined: 25 Jun 2008
  • Posts: 21
  • Loc: Poland
  • Status: Offline

Post December 1st, 2008, 1:48 pm

Ok, I guess I'll do it with include, thanks for advices.

Post December 14th, 2008, 10:21 pm

You can also use the eval() function in php to evaluate code.

http://us.php.net/eval

Post Information

  • Total Posts in this topic: 5 posts
  • Moderator: Moderator Team
  • Users browsing this forum: No registered users and 119 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.