processs php commands embedded in database table
Posted: Thu Jul 30, 2009 9:30 am
I have a number of web sites which share information and after looking at using include to utilise common files/data I found that there maybe security issues with this and my hosting service has allow_url_include set to false (0).
All of my websites are hosted on the same host and therefore can share the database which I have set up, so I migrated a lot of the shared logic to ustilise information from the database which is working well but in addition to data on the database which controls what the sites show etc, I also want to use shared pages from the database. The problem I am having is that the data retrieved from the database is not processed by php.
An example of what I am trying to is a simple contact page.
contact.php would contain the following:- (note error processing removed)
echo '<!DOCTYPE html PUBLIC .......
$SiteURL = ($_SERVER['SERVER_NAME']);
$DBConn = mysql_connect(localhost,$WSDBU,$WSDBP);
$db_selected = mysql_select_db($WSDB, $DBConn);
$DBResult = mysql_query("SELECT PageContents FROM Pages");
$num=mysql_numrows($DBResult);
echo $DBResult; blah blah
$DBResult, i.e. the data retrieved from the database contains the following piece of code <p> Please visit our site at <?php echo $SiteURL; ?></p>
But instead of displaying the contents of $SiteURL the page displays the actual php code.
Please tell me if what I am treying to do is possible.
I have only been programming with PHP and MYSQL for a few months now and I love it and I am sure what I am trying to do is acheivable.
Thanks
All of my websites are hosted on the same host and therefore can share the database which I have set up, so I migrated a lot of the shared logic to ustilise information from the database which is working well but in addition to data on the database which controls what the sites show etc, I also want to use shared pages from the database. The problem I am having is that the data retrieved from the database is not processed by php.
An example of what I am trying to is a simple contact page.
contact.php would contain the following:- (note error processing removed)
echo '<!DOCTYPE html PUBLIC .......
$SiteURL = ($_SERVER['SERVER_NAME']);
$DBConn = mysql_connect(localhost,$WSDBU,$WSDBP);
$db_selected = mysql_select_db($WSDB, $DBConn);
$DBResult = mysql_query("SELECT PageContents FROM Pages");
$num=mysql_numrows($DBResult);
echo $DBResult; blah blah
$DBResult, i.e. the data retrieved from the database contains the following piece of code <p> Please visit our site at <?php echo $SiteURL; ?></p>
But instead of displaying the contents of $SiteURL the page displays the actual php code.
Please tell me if what I am treying to do is possible.
I have only been programming with PHP and MYSQL for a few months now and I love it and I am sure what I am trying to do is acheivable.
Thanks