NameSilo

Parsing errors

Spacemail by SpaceshipSpacemail by Spaceship
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
Hi all im doing a template system and ive run into this error;

Warning: parsefile(admin): failed to open stream: No such file or directory in /home/fedrabb/public_html/forum/includes/templating.php on line 39

Warning: parsefile(): Failed opening 'admin' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fedrabb/public_html/forum/includes/templating.php on line 39

That comes up when i try and parse {user} with the word 'admin'

This is the code;

PHP:
class templateParser 
{
	var $output;

	function templateParser($templateFile)
	{
		(file_exists($templateFile))?$this->output=file_get_contents($templateFile):error($lang['title']['error'],$lang['text']['template_not_found']);
	}

    function parseTemplate($tags=array())
	{
		if(count($tags)>0)
		{
			foreach($tags as $tag=>$data)
			{
				$data=(file_exists($data))?$this->parseFile($data):$data;

				$this->output=str_replace('{'.$tag.'}',$data,$this->output);
			}

		}

		else 
		{
			error($lang['title']['error'],$lang['text']['no_tags']);
		}

	}

	function parseFile($file)
	{

		ob_start();

		include($file);

		$content=ob_get_contents();

		ob_end_clean();

		return $content;

	}

	// display the page
	function display()
	{
		echo $this->output;
	}

}

Any ideas? - can be seen at http://www.fedrabb.net/forum/members.php
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
did you set permissions correctly ? because it cant open the file.
 
0
•••
As i said in my post i try to parse the word admin not file, admin is not a file for some reason it thinks it is!!
 
0
•••
maybe because you are doing include($file) it searches for the file.
 
0
•••
I have found the problem;

$data=(file_exists($data))?$this->parseFile($data):$data;

that should read

$data=(file_exists($file))?$this->parseFile($file):$data;

Looks like the author on devshed didnt really know what he was doing...good job i do...
 
0
•••
liam_d said:
I have found the problem;

$data=(file_exists($data))?$this->parseFile($data):$data;

that should read

$data=(file_exists($file))?$this->parseFile($file):$data;

Looks like the author on devshed didnt really know what he was doing...good job i do...

Good job for catching it. Unfortunately so many tutorials (not just Devshed) just don't work because it seems they didn't test the actual code :)

The bright said is that it makes everyone a better coder

liam_d said:
I have found the problem;

$data=(file_exists($data))?$this->parseFile($data):$data;

that should read

$data=(file_exists($file))?$this->parseFile($file):$data;

Looks like the author on devshed didnt really know what he was doing...good job i do...

Good job for catching it. Unfortunately so many tutorials (not just Devshed) just don't work because it seems they didn't test the actual code :)

The bright side is that it makes everyone a better coder
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back