Jump to content

[SOLVED] Run PHP from MySQL Database - eval?


AshleyByrom

Recommended Posts

Hey, right I wouldn't say I'm a complete beginner but I'm definitely not the best.

 

I am making a website, with a fairly basic CMS. Each page is stored in a row in a table (shown below)

 

id

name

content

1

Home

<b>HELLO</b> there <u>welcome</u> to the site.

2

About us

<b>HELLO</b> there <u>welcome</u> to the about bit.

 

hopefully you can understand how the basic principles work, by going to mywebsite.com?id=1 you would see the first 'page'. mywebsite.com?id=2 would give you the second 'page' and so on...

 

Plus, the html stored in the database has all the characters converted as you can see. Using html_entity_decode i convert all these characters back. Right, here is my problem.

 

I want to have some PHP code mixed in with the HTML stored in the database. I have looked at eval but that appears to just handle PHP code, not PHP and HTML? Unless I am mistaken... Here is the actual code I have (including PHP)

 

<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" valign="top"><table border="0" align="left" cellpadding="10" cellspacing="0" background="images/qouteback.gif" width="260" height="165" style="background-repeat: no-repeat; top: 5px; left:5px;">
            <tr>
              <td width="229" align="left" valign="top"><table width="52" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top" height="5"></td>
                </tr>
                <tr>
                  <td valign="top"><div class="newsCal">
                    <div class="newsCalMonth">
                      <?php $month = date("M"); $day = date("d"); echo $month; ?>
                    </div>
                    <div class="newsCalDay"><?php echo $day; ?></div>
                  </div></td>
                </tr>
              </table>
                <font size="+1"><u>New Website!</u></font><br />
                We'd like to welcome you to the brand new website we have. Hopefully you will find the site easier to use and more informative.<br />
                <br />
                There have been lots and <strong>lots</strong> of changes so let's hope they were for the best!</td>
            </tr>
          </table></td>
          <td><div style="text-align:justify;"> A City Learning Centre's purpose is to promote and develop new and exciting ways 				of learning through the use of Information and Communication Technology (ICT). The CLC combines state-of-the-art facilities and expertise to provide learning opportunities to a network of local schools (primary and secondary), the local community and local businesses.<br />
            <br />
            The model of the City Learning Centre, working in true partnership with local schools, community and business, <strong><blink>[THIS IS WAY TOO MUCH TEXT FOR A INDEX PAGE - JUST A GAP FILLER]</blink></strong>is set to transform urban education. South Manchester CLC will enhance learning by providing courses and opportunities for individual pupils, delivering services and outreach support for a wider network of local schools, including providing extension activities for Gifted and Talented pupils and study support, acting as a test bed for innovation and new ways of teaching and learning and cascading best practice amongst the local network of schools and other facilities.<br />
  <br />
            There is a huge potential to be derived from collaboration between all sectors of education, sharing a common purpose to develop state-of-the-art technology to transform teaching and learning in schools, colleges, businesses and within the local community.<br />
  <br />
            There are 4 CLC's based within Manchester including Central, North West, North East and of course South Manchester City Learning Centre with a total of 104 CLC's around the country. </div></td>
        </tr>
      </table>

 

Hope you understand and can help! Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/178947-solved-run-php-from-mysql-database-eval/
Share on other sites

Remember that eval has some serious drawbacks

1. It is slow - but if you will be using it only for simple templates, that shouldn't be an issue

2. It is unsecure - someone might insert malicious PHP code into one of your templates and eval will execute it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.