Jump to content

Recommended Posts

Ok I'll try again :)

 

I've always stayed away from eval because it confuses me a little :D. I've read over php.net's examples many times now, but something still isn't clicking.

 

I was just throwing out an example but i guess my question is, is it possible to run stored code from the data base? Like say I have this piece of code:

 


$username=$_SESSION['user'];

echo "Username is $username";

 

Now, is there a way for me to save that in a text field (or watever field is applicable) then query the DB, get that snippet, and run it as code? As far as I understood that is what eval is used for. I've tried and failed miserably to run it, moving around \ and " and $ to no avail in my evals :o.

 

So my question is, if I had that string in the DB and I got it, like so:

 


$res=mysql_query("SELECT * FROM `strings` WHERE `id`='1'");
$row=mysql_fetch_array($res);

$string=$row['string'];

 

String now has the aforementioned username/session code in it. So how can I tell php it is code and run it?

 

Thanks to all, and sorry to ramble and confuse. Eval is one thing I've never been able to get!

Link to comment
https://forums.phpfreaks.com/topic/165256-solved-eval-code/#findComment-871984
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.