DeanWhitehouse Posted May 7, 2008 Share Posted May 7, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/104498-solved-fwrite-problems/ Share on other sites More sharing options...
moselkady Posted May 7, 2008 Share Posted May 7, 2008 Are escaping " and \n in your strings so they become \" and \\n ? Quote Link to comment https://forums.phpfreaks.com/topic/104498-solved-fwrite-problems/#findComment-534981 Share on other sites More sharing options...
DeanWhitehouse Posted May 7, 2008 Author Share Posted May 7, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/104498-solved-fwrite-problems/#findComment-535345 Share on other sites More sharing options...
moselkady Posted May 7, 2008 Share Posted May 7, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/104498-solved-fwrite-problems/#findComment-535360 Share on other sites More sharing options...
DeanWhitehouse Posted May 7, 2008 Author Share Posted May 7, 2008 yer, i had , i had just noticed, i had them typed so that they would be correct in the .inc.php file. Quote Link to comment https://forums.phpfreaks.com/topic/104498-solved-fwrite-problems/#findComment-535363 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.