Jump to content

PHP Function held in database


themistral

Recommended Posts

Guys, I am stumped!

 

I have a website where the content is held in a database.

For example a table called page_content has a field called content.

Held in that field is the following text "This is the page text."

 

This is all fine - I have the scripts all set up so I can retrieve this.

 

However, I want to be able to store and retrieve the following:

 

"This is the page text. <?php echo functionName(); ?>"

The content is brought into a page that includes the function.

 

Firstly, is this possible - secondly, how is this possible?!

 

I have been trying to get my head around the eval function but I am still not sure this is will do what I want.

 

Any help gratefully received!!  ;D

Link to comment
Share on other sites

yeh this is very bad. You can never 100% guarantee the sanitization of a database. What if someone gained access to it? They could insert whatever php they wanted into your database and your scripts could potentially run it. In PHP potentially system wide changes could be made, for instance deleting the entire contents of the server.

 

Also, what if you refactored your code and consequently deleted that function? Then the database is out of date and will prompt an error, and there's no easy way of updating it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.