PHP code in a MySQL record
| From: | Nathaniel Hall | Date: | Fri, 29 Jul 2005 02:13:13 +0000 |
| Subject: | PHP code in a MySQL record | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219570@lists.php.net to get a copy of this message | ||
I am working on a project that uses an index.php page. Depending on the
variable in the URL, a different php page is included. I have a
config.php that contains variables that are accessible from any page.
That is the easy part.
I have some pages pulling HTML out of a database. I would like to be
able to reference some of the variables in the config.php in the
database blob field. Here is an example:
index.phphalln_\@_otc_\._edu
------
<html><head>...etc
<?php
include 'config.php';
if (blabla) {
include "thispage.php";
} else {
include "thatpage.php";
}
?>
config.php
------
<?php
$this_var=1;
$that_var="Nothing";
?>
test.php
------
<?php
$query="SELECT * from table";
$result=mysql_query($query) or die ("Cannot process query");
$row=mysql_fetch_row($result);
echo $row[1];
?>
MySQL record:
------
id,year,month,day,entry
1,2005,01,01,This is a test<br><? echo $that_var; ?>
_____________________________
I have tried using <br>>? echo $that_var; ?< and I have tried
escaping everything, but that still didn't work. Any ideas?
Nathaniel Hall
halln_\@_otc_\._edu