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
https://forums.phpfreaks.com/topic/169119-created-file-wont-run-php/
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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.