Jump to content

Recommended Posts

This question sort of comes out of my last question, but has little to do with it.

 

I am using fwrite to create a page which looks basically like this:

 

<?php

include('includes/sql_connect.php');

 

$select_header = mysql_query("SELECT template_header FROM $general_table WHERE id = '1'");

while ($header_row=mysql_fetch_row($select_header)) { echo $header_row[0]; }

 

$select_content = mysql_query("SELECT content FROM $pages_table WHERE id = '1'");

while ($content_row=mysql_fetch_row($select_content)) { echo $content_row[0]; }

 

$select_footer = mysql_query("SELECT template_footer FROM $general_table WHERE id = '1'");

while ($footer_row=mysql_fetch_row($select_footer)) { echo $footer_row[0]; }

?>

 

It gets the template header from the database, then the page content, and then the template footer. This way, everything can be edited dynamically.

 

Now, when the page is generated, it generates PHP code as if it were html code. That is, it actually shows the php code instead of using it.

The page extension is .php, so thats not the problem. How can i get the generated page to use php code as php code instead of html.

 

Here is an example (taken directly from looking at the "page source" of one of the generate pages):

 

<div class="body">

<div class="main_buttons_container">

<?php

$site_url = mysql_query("SELECT website_url FROM $general_table WHERE id = '1'");

?>

<a href="<?php while ($url_row=mysql_fetch_row($site_url)) { echo $url_row[0]; } ?>" class="main_buttons">View Site</a><a href="mail.php" class="main_buttons">View Mail</a><a href="logout.php" class="main_buttons">Log Out</a>

 

</div>

 

The php shows instead of doing what it should.

 

Any ideas? Even if you don't know how to solve the problem, can you identify it?

 

Thanks!

Just for future reference, i did this a really dumb way, so i changed it. I instead used the database to call specific things (such as links) and used include to include php files with the header and footer. I know it doesn't solve exactly what i wanted, but this works for what i am using it for.

 

Thanks for the help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.