Jump to content

[SOLVED] fwrite problems


Recommended Posts

i am trying to write this to a file

this is only an extract of the code

$mainpage = "/home.php";
$sitetitle = "Random Template System";
$homepage = "http://" . $_SERVER["SERVER_NAME"];
$titlepage = "http://" . $_SERVER["SERVER_NAME"].$mainpage;
$customheader = '<a class="title" href="$home_page.$main_page">$site_title</a>';
$h_ome = "Home";
$int_ro = "Welcome, this is a test of the sites features.Please go to the admin centre to cutomize the site.";
$wel_come = 'wordwrap($intro, 70, "<br />\n", true)';
$di_sc = "This is the site disclaimer. Here is where most sites have copyright information and other things.";
$sitedisclaimer = 'wordwrap($disc, 130, "<br />\n", true)';
$st_yle = "style.css";

 

this is the code i am using to write it

<?php

// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
require_once 'install.php';
$config_file = "../includes/main.inc.php";

$fw=fopen($config_file,"w+") 
or die("Unable to open file!");	// Unable to open file

$config_homepg = "\$home_page = \"".$homepage."\";\n";
$config_main = "\$main_page = \"".$mainpage."\";\n";
$config_title = "\$site_title = \"".$sitetitle."\";\n";
$config_titlepg = "\$title_page = \"".$titlepage."\";\n";
$config_customhead = "\$custom_header = \"".$customheader."\";\n";
$config_home2 = "\$home = \"".$h_ome."\";\n";
$config_intro = "\$intro = \"".$int_ro."\";\n";
$config_welcome = "\$welcome = \"".$wel_come."\";\n";
$config_disc = "\$disc  = \"".$di_sc."\";\n";
$config_sitedisc = "\$site_disclaimer = \"".$sitedisclaimer."\";\n";
$config_style = "\$style = \"".$st_yle."\";\n";

$config_write = $config_homepg.$config_main.$config_title.$config_titlepg.$config_customhead.$config_home2.$config_intro.$config_style.$config_sitedisc.$config_disc.$config_welcome;

fwrite($fw, "<?php\n".$config_write."\n?>");

fclose($fw);

?>

 

i can't seem to write some of the variables properly

these are the one's that don't work

 

$custom_header = "<a class="title" href="$home_page.$main_page">$site_title</a>";

$site_disclaimer = "wordwrap($disc, 130, "<br />\n", true)";

$welcome = "wordwrap($intro, 70, "<br />\n", true)";

 

i get a page error when viewing a page using the custom_header variable.

can anyone help?

Link to comment
Share on other sites

still having a problem with this,

this is my code

variables

$mainpage = "/home.php";
$sitetitle = "Random Template System";
$homepage = "http://" . $_SERVER["SERVER_NAME"];
$titlepage = "http://" . $_SERVER["SERVER_NAME"].$mainpage;
$customheader = "<a class='title' href='$home_page.$main_page'>$site_title</a>";
$h_ome = "Home";
$int_ro = "Welcome, this is a test of the sites features.Please go to the admin centre to cutomize the site.";
$wel_come = wordwrap($intro, 70, "<br />\n", true);
$di_sc = "This is the site disclaimer. Here is where most sites have copyright information and other things.";
$sitedisclaimer = wordwrap($disc, 130, "<br />\n", true);
$st_yle = "style.css";

 

and this is what is wrote

<?php
$home_page = "http://deanwhitehouse.awardspace.co.uk";
$main_page = "/home.php";
$site_title = "Random Template System";
$title_page = "http://deanwhitehouse.awardspace.co.uk/home.php";
$custom_header = "<a class='title' href='.'></a>";
$home = "Home";
$intro = "Welcome, this is a test of the sites features.Please go to the admin centre to cutomize the site.";
$style = "style.css";
$site_disclaimer = "";
$disc  = "This is the site disclaimer. Here is where most sites have copyright information and other things.";
$welcome = "";

?>

 

the writing code

<?php

// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
require_once 'install.php';
$config_file = "../includes/main.inc.php";

$fw=fopen($config_file,"w+") 
or die("Unable to open file!");	// Unable to open file

$config_homepg = "\$home_page = \"".$homepage."\";\n";
$config_main = "\$main_page = \"".$mainpage."\";\n";
$config_title = "\$site_title = \"".$sitetitle."\";\n";
$config_titlepg = "\$title_page = \"".$titlepage."\";\n";
$config_customhead = "\$custom_header = \"".$customheader."\";\n";
$config_home2 = "\$home = \"".$h_ome."\";\n";
$config_intro = "\$intro = \"".$int_ro."\";\n";
$config_welcome = "\$welcome = \"".$wel_come."\";\n";
$config_disc = "\$disc  = \"".$di_sc."\";\n";
$config_sitedisc = "\$site_disclaimer = \"".$sitedisclaimer."\";\n";
$config_style = "\$style = \"".$st_yle."\";\n";

$config_write = $config_homepg.$config_main.$config_title.$config_titlepg.$config_customhead.$config_home2.$config_intro.$config_style.$config_sitedisc.$config_disc.$config_welcome;

fwrite($fw, "<?php\n".$config_write."\n?>");

fclose($fw);

?>

Link to comment
Share on other sites

 

I think you may have mistyped some variable names, like $home_page instead of $homepage. If so, these 3 variables can be fixed as follows:

 

$customheader = "<a class='title' href='$homepage.$main_page'>$site_title</a>";
$wel_come = wordwrap($int_ro, 70, "<br />\n", true);
$sitedisclaimer = wordwrap($di_sc, 130, "<br />\n", true);

 

 

Link to comment
Share on other sites

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.