dcyuri7 Posted January 30, 2007 Share Posted January 30, 2007 I've been attempting to research how to do this, but I am having very little luck. Basically, I am trying to run PHP code from a mysql returned string. Looks like this:[code]<?php // Database Connect (not typed fully - no need for you to see it, or me to type it)init_db.... and connection_of_db/ etc// Request info (dont mind this too much either - except for the "Content_Main" var)$sql_query=mysql_query("SELECT * FROM contentareas WHERE Page='{$_GET['id']}' AND SetName='Main'"); $Content_Main=mysql_result($sql_query,0,"Data");// If I were to echo Content_Main, it would show this:echo "echo \"<p class=\\"secondary\\">; print \"Hello World\"; echo \"</p>\";";// Heres my problem!!unknown_PHPfunction($Content_Main); // I want it to execute the code in the stored String, which happens to be most specifically:// print \"Hello World\"; -- And of course the two echo's surrounding it.[/code]Any help is greatly appreciated,yuri Link to comment https://forums.phpfreaks.com/topic/36397-string-variable-procedure-storage/ Share on other sites More sharing options...
dcyuri7 Posted January 31, 2007 Author Share Posted January 31, 2007 lol looks like people are discouraged cause i made it complicated...All i need to do is:take $string;$string='echo "Bla";'then:some_cmd($string);Just need to run a php command using a string variable.Kind of like an include(); except not with files, with variables. ;) Link to comment https://forums.phpfreaks.com/topic/36397-string-variable-procedure-storage/#findComment-173291 Share on other sites More sharing options...
corbin Posted January 31, 2007 Share Posted January 31, 2007 I don't understand your question completely, but I think you are looking for eval (http://php.net/eval) Link to comment https://forums.phpfreaks.com/topic/36397-string-variable-procedure-storage/#findComment-173302 Share on other sites More sharing options...
dcyuri7 Posted January 31, 2007 Author Share Posted January 31, 2007 workin on it now, looks promising... Link to comment https://forums.phpfreaks.com/topic/36397-string-variable-procedure-storage/#findComment-173499 Share on other sites More sharing options...
dcyuri7 Posted January 31, 2007 Author Share Posted January 31, 2007 thats it, thanks a ton bro. Link to comment https://forums.phpfreaks.com/topic/36397-string-variable-procedure-storage/#findComment-173507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.