Leo Posted August 27, 2006 Report Share Posted August 27, 2006 (edited) I am attempting to get to know php but cannot get the simplest of pages to work. I have installed apache 2.0.54 and php 5.0.4 I have copied a script: <?php if (!isset($page)) $page = 'default.html'; $page = "$page"; $fp = fopen($page,"r"); $content = fread($fp, filesize($page)); fclose($fp); $content = str_replace('[HEADER]','<?php include\'header.php\';?>', $content); $content = str_replace('[FOOTER]','<?php include\'footer.php\';?>', $content); $content = str_replace('[NEWSLETTERSIGNUP]','<?php include\'nlsignup.php\';?>', $content); eval('?>'.$content); ?> and the relevant html files as well as an html file called welcome.html: [HEADER] Welcome to some text [NEWSLETTERSIGNUP] [FOOTER] When I attempt to display the file however using http://localhost/default.php?page=welcome.html in firefox, nothing is displayed. My apache log shows the following errors: [client 127.0.0.1] PHP Warning: fopen(default.html) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /var/www/html/default.php on line 6 [client 127.0.0.1] PHP Warning: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for default.html in /var/www/html/default.php on line 7 [client 127.0.0.1] PHP Warning: fread(): supplied argument is not a valid stream resource in /var/www/html/default.php on line 7 [client 127.0.0.1] PHP Warning: fclose(): supplied argument is not a valid stream resource in /var/www/html/default.php on line 8 all the files are saved under /var/www/html. If I amend the code to set $page to the welcome.html file then it all works, but it will not allow me to pass in the file as an argument. I hae a suspicion that it is my setup that is wrong but do not know where to start. Any help would be grtatefully received. thanks Leo Edited August 27, 2006 by Leo Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted August 27, 2006 Report Share Posted August 27, 2006 You have to set $page. Just passing it in the url is not enough: $page = $_GET['page']; Or something like that. Quote Link to comment Share on other sites More sharing options...
Leo Posted August 27, 2006 Author Report Share Posted August 27, 2006 cool. That works perfectly. Thanks Leo Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.