NameSilo

Parsing errors

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
did you set permissions correctly ? because it cant open the file.
 
0
Close
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
Close
maybe because you are doing include($file) it searches for the file.
 
0
Close
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
Close
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
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back