Executing PHP stored in MySQL-database?
| From: | aquariuz | Date: | Thu, 24 May 2001 09:01:34 +0000 |
| Subject: | Executing PHP stored in MySQL-database? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-54184@lists.php.net to get a copy of this message | ||
Hi,
Is it possible to execute PHP stored in a MySQL-database?
If so, how to do it?
In the example below I store "Hello world!<BR>" in a database, and next I
echo it. "Hello world!" is printed on the screen.
But how to
* store PHP-code in a database
* and execute it?
Any help would be appreciated.
Greetz,
aquariuz
---
<?PHP
$connect=@mysql_connect($dbhost,$dbuser,$dbpassword);
if($connect) {
mysql_select_db($dbname);
$sql=mysql_query("DELETE FROM test WHERE id=1");
$sql=mysql_query("INSERT INTO test (id, query) VALUES (1, 'Hello
world!<BR>')");
$query="SELECT query FROM test WHERE id=1";
$sql=mysql_query($query);
$row=mysql_fetch_array($sql);
echo $row["query"];
}
?>