Rather than writing the code to a temporary file and then including the file why not just use eval() on the code fetched from the database (http://www.php.net/eval)?

Otherwise you could use generate a unique filename yourself rather than using tmpfile.

$filename = md5(uniqid());

Of course you may want to through some checking in there to make sure the file doesn't already exist but the chances of getting the same exact filename in the short time the file is required is fairly low.

Jason

Lars Tvedt wrote:
Im trying to create a way of storing php scripts in a mySQL database, and
then execute them using temporary files as executable script buffers..
The database retrieval is working fine but the file does not...

Ive got a table with 4 fields: execID, execName, execDesc and execProc
The last one contains php code.

This is what i have so far:


<?php mysql_connect($host,$user,$pw); mysql_select_db($db); $query = "SELECT execProc FROM exec WHERE execID = 1"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $proc = $row['execProc']; } $handle = tmpfile(); fwrite($handle, $proc); include("name of the temporary file"); fclose($handle); ?>



But i need to get the name of the tempfile in order to include it..
All i have now is the handle_id
Any help appreciated.





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



Reply via email to