Re: [PHP] embedding PHP in MySQL

2003-09-18 Thread Marek Kilimajer
By default the evaled code is php, so you need to escape first:
eval('?>'.$your_code_pulled_from_db.'
Michael Winston wrote:

I've been working on this for a few days and can't get it.

I would like to stick some php code into a sql databases and be able to 
evaluate it when it's called up.

Foe example, let's say there's some text in a table in MySql that says 
"blah blah blah  blah blah blah blah blah".  I wan the end, displaying 
result to be: "blah blah blah {executed php code} blah blah blah  blah".

Now, I know that eval() is involved, but I don't want it accidentally 
executing code outside the "" so I need a way to pluck out bits of 
code, evaluate them, and put them back in.

Any ideas?

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


RE: [PHP] embedding PHP in MySQL

2003-09-18 Thread Javier Tacon

Instead to eval the code, try to save the query result into a new file, then execute 
this file (require_once, include).

Something like:

function executeFromQuery($query) {
  global $DB;
  $file = "/tmp/temp.php";
  $code = $DB->getOne($query);
  $fh = fopen($file,"w");
  fwrite($fh,$code);
  fclose($fh);
  include($file);
}

It should work.

Javier Tacón Iglesias.


-Mensaje original-
De: Michael Winston [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 18 de septiembre de 2003 17:20
Para: [EMAIL PROTECTED]
Asunto: [PHP] embedding PHP in MySQL
Importancia: Baja


I've been working on this for a few days and can't get it.

I would like to stick some php code into a sql databases and be able to 
evaluate it when it's called up.

Foe example, let's say there's some text in a table in MySql that says 
"blah blah blah  blah blah blah blah blah".  I wan the end, 
displaying result to be: "blah blah blah {executed php code} blah blah 
blah  blah".

Now, I know that eval() is involved, but I don't want it accidentally 
executing code outside the "" so I need a way to pluck out bits 
of code, evaluate them, and put them back in.

Any ideas?

Thanks,
Michael

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

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



[PHP] embedding PHP in MySQL

2003-09-18 Thread Michael Winston
I've been working on this for a few days and can't get it.

I would like to stick some php code into a sql databases and be able to 
evaluate it when it's called up.

Foe example, let's say there's some text in a table in MySql that says 
"blah blah blah  blah blah blah blah blah".  I wan the end, 
displaying result to be: "blah blah blah {executed php code} blah blah 
blah  blah".

Now, I know that eval() is involved, but I don't want it accidentally 
executing code outside the "" so I need a way to pluck out bits 
of code, evaluate them, and put them back in.

Any ideas?

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