I don't know if this is possible but...

I want to generate a PHP file on the fly. I am trying to use fputs but I
have a problem in that it doesn't print a variable name in the string.
Here is my code:

Formid is being passed into the string great which is what I want but
how do I get the string to write the variable names in this code? Are
there any rules I need to follow to get the whole file to print out? If
so what? And what should I be looking for in the manual? Fputs isn't
helping much.

function generate_page($formid, $pagename)
{
// Give the function the string to be generated including formid passed
from 
// previous form
$string = "<?php $SECTION_NAME = \"goldfish_cms.php\";\n
////////////////////////////////////////////////////////////////////////
//////////\n
// Written by Steve Jackson. Copyright and all rights reserved Webpage
2003.//////\n
/////////////////functions here all included in
output_fns.php////////////////////\n
////////////////////////////////////////////////////////////////////////
//////////\n
  // include the files from output fns to get functions which design the
page\n 
  include ('output_fns.php');\n
  db_connect();\n
  $query = \"select * from content where PageID='$formid'\";\n
  $result = mysql_query($query) or die(\"Error: Query failure
with<BR>$query<BR>\".mysql_error());\n
  while ($array = mysql_fetch_array($result))\n
  {\n
  $HeadTitle = \"{$array["HeadTitle"]}\"; \n
  $PageTitle = \"{$array["Title"]}\"; \n
  $BodyText = \"{$array["BodyText"]}\";\n
  $Picture1 = \"{$array["PictureOne"]}\";\n
  $Picture2 = \"{$array["PictureTwo"]}\";\n
  $CatID = \"{$array["CatID"]}\";\n
  }\n
  // carry the variable head title in the page and do the page header\n
  do_html_header($HeadTitle);\n
  // carry variables into do_html_index() function in output_fns.\n
  // Page title = The headline of the page\n
  // Body text = The text body, can include html commands.\n
  // Picture 1 = picture or graphic that appears above the title if
required.\n
  // Picture 2 = Picture that appears right hand side on the basic
output_fns\n
  // CatID = Category which is used for determining which links appear
on each page\n
  // Section name = Allows you to specify extra functions to
output_fns.php to be unique to the page (requires hard coding)\n
  do_html_index($PageTitle, $BodyText, $Picture1, $Picture2, $CatID,
$SECTION_NAME);\n       
  // put the page footer in position\n  
  do_html_footer();\n
?>\n";
$filename = 'test.txt';
$fp = fopen($filename, "a");
$write = fputs($fp, $string);
fclose($fp);
}
generate_page($formid, $pagename);

Steve Jackson
Web Development and Marketing Manager
Viola Systems Ltd.
http://www.violasystems.com
[EMAIL PROTECTED]
Mobile +358 50 343 5159


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to