Re: storing function names in db and running them as row is output?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



blackwater dev wrote:
First, the example I have is not the real situation, just an example so I
don't want to get into why are you doing it like that, etc.  Just want to
see if it's possible.

Basically, I want to store stuff in a text field in a db like this "johns
name is ucfirst('john adams') ".

When I cycle through that row for output in my php script, I want it to not
see ucfirst as text but as the php function and run it....how is the
possible?

Thanks.


$db_query = mysql_query("select command from table");
if ($db_query && mysql_num_rows($db_query) > 0) {
  while ($array = mysql_fetch_array($db_query)) {
    eval($array['command']);
  }
}

eval() is your solution.

--
Christopher Weldon, ZCE
President & CEO
Cerberus Interactive, Inc.
cweldon@xxxxxxxxxxxxxxxxxx
979.739.5874

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux