JustGotAQuestion Posted December 23, 2007 Share Posted December 23, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/82971-solved-using-fwrite-and-mysql-to-create-a-php-page/ Share on other sites More sharing options...
JustGotAQuestion Posted December 24, 2007 Author Share Posted December 24, 2007 I still really need help with this. Did i explain what is wrong clear enough? Or does nobody know? Quote Link to comment https://forums.phpfreaks.com/topic/82971-solved-using-fwrite-and-mysql-to-create-a-php-page/#findComment-422251 Share on other sites More sharing options...
PHP_PhREEEk Posted December 24, 2007 Share Posted December 24, 2007 You'll need to look into eval() PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/82971-solved-using-fwrite-and-mysql-to-create-a-php-page/#findComment-422286 Share on other sites More sharing options...
JustGotAQuestion Posted December 25, 2007 Author Share Posted December 25, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/82971-solved-using-fwrite-and-mysql-to-create-a-php-page/#findComment-422721 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.