Jump to content

Created File Won't Run PHP?


The14thGOD

Recommended Posts

I am creating new pages from "templates" (not actual .tpl files) however when I go to view the page, the page just shows the html portion. None of the includes are triggered to bring in the css/js head links, navigation, or the footer. I download the files from the server and everything is right. I tried setting permissions to 755 and 644 (this is what all the files i uploaded via ftp appear as) using:

<?php
chmod("../$newpage",0644);
		chmod("$newpage",0644);?>

But that's not doing anything.

 

Does anyone know what I have to do in order to get the PHP code to work?

 

Thanks for any and all help,

Justin

Link to comment
Share on other sites

Perhaps I should rephrase this... I'm creating pages from templates using PHP for a CMS. However when I go to view the pages created the PHP doesn't run so I'm left with half a page. Is there something else in the code to create a file that I need to specify in order for the PHP code to run?

 

<?php
//open files for reading
		$fh = fopen ($filename, "r") or die ("couldn't open file");
		$fh2 = fopen ($filename2, "r") or die ("couldn't open file");
		//get data from files
		$data = fread($fh,filesize($filename));
		$data2 = fread($fh2,filesize($filename2));
		//close files
		fclose($fh);
		fclose($fh2);
		//new files
		$fh = fopen("../$newpage","w") or die ("couldn't make file");
		$fh2 = fopen("$newpage","w") or die ("couldn't make file2");
		//replace content in the data
		$data = str_replace('0000000000',"$pageid",$data);
		$data2 = str_replace('0000000000',"$pageid",$data2);
		//Proper navigation heading?
		switch($parent_page){
			case 1: //home
				$data = str_replace('<body>','<body id="page1">',$data);
				$data2 = str_replace('<body>','<body id="page1">',$data2);
				break;
			//etc etc....
		}
		//write the data into the files
		fwrite($fh,$data);
		fwrite($fh2,$data2);
		//close files
		fclose($fh);
		fclose($fh2);			
		//set permissions
		chmod("../$newpage",0644);
		chmod("$newpage",0644);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.