View Full Version : php coding assistance with templete.php

12-23-2005, 07:21 PM
I get this error:

Warning: feof(): supplied argument is not a valid stream resource in /home/herbals/public_html/community/membersonly/template.php on line 48

Warning: fgets(): supplied argument is not a valid stream resource in /home/herbals/public_html/community/membersonly/template.php on line 49

Here is my code:

class: template
purpose: template engine
class template extends membersonly{

function: define_file
purpose: defines template file
function define_file($file){

function: add_region
purpose: adds template dynamic region
function add_region($region,$value){

function: debug
purpose: set debugging to true
function debug(){

function: make_template
purpose: make and display template
function make_template() {
$fp = @fopen($this->membersonly_path.$this->template_dir.$this->template_file,"r");
for ($i=0; $i<$regioncount; $i++){
if ($this->template_regions[$i]=="headers"){
$page.="<!--This community runs on Herbal Sacred Ground Web Hosting ".$this->membersonly_version."\nhttp://herbalsacredground.com-->\n";
while (!feof($fp)){
$line = fgets($fp);
$line = stripslashes($line);
$line = preg_replace("/href=\"..\//","href=\"".$this->membersonly_webpath,$line);
$line = preg_replace("/src=\"..\//","src=\"".$this->membersonly_webpath,$line);
for ($i=0; $i<$regioncount; $i++){
$line = preg_replace("/{".$this->template_regions[$i]."}/",$this->template_regionvalues[$i],$line);
$temp = @fopen($tempfile,"w+");
fwrite($temp, $page);
include ($tempfile);
if ($this->template_debug=="false"){


Velox Letum
12-23-2005, 08:06 PM
It looks like the file doesn't exist to me, or you don't have permissions to modify it.

12-23-2005, 08:39 PM
What do you mean?

12-23-2005, 08:47 PM
Putting @ in front of functions before you know they work is really silly.
Try fopen(...) or die("COuldn't open file on line xxx");
instead, and it might be helpful

12-23-2005, 09:02 PM
Also, please wrap your code in [PHP] tags as described here (http://www.icdsoftware.com/tags).