Selacius Posted March 16, 2006 Share Posted March 16, 2006 I am creating an online RPG, which is why I've asked so many questions around here. This next question is probably my biggest and hardest one yet. I am curious how and if I can put and later execute PHP code in a table entry. This is for my quest system and instead of having billions of pages for each quest, I would rather insert the php code necessary for each quest in the database. So for example, if I have an NPC which will initiate the quest, then in the NPCs database entry I will have one column where I would put some php code, such as mysql_queries, mathematics etc. I hope this is easy to understand. Thanks. Link to comment Share on other sites More sharing options...
hacknsack Posted March 16, 2006 Share Posted March 16, 2006 Sounds like eval() is what you need.http://us2.php.net/manual/en/function.eval.php-hs Link to comment Share on other sites More sharing options...
Selacius Posted March 16, 2006 Author Share Posted March 16, 2006 Yea, I thought so too. I was testing it out completely wrong. But when I inserted the actual code into the database and did a mysql_query and such, the outputted value was the actual code that I had in the table value. So I tried eval, but I got this error: Parse error: parse error, unexpected T_VARIABLE in c:\ibserver\www\test\text2.php(8) : eval()'d code on line 1This is the code which is found in the column: $result = mysql_db_query ("$dbs","SELECT * FROM enemy WHERE eid='0'"); $row = mysql_fetch_array($result); $ename = $row['ename']; $estr = $row['estr']; $emin = 1.25 * $estr; echo "$ename - $emin"; Link to comment Share on other sites More sharing options...
Selacius Posted March 16, 2006 Author Share Posted March 16, 2006 Nm. I got it figured out. I was using some whacked out code for eval, that was giving me that error. I got it figured out. Woo Hoo. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now