Zeradin Posted July 29, 2008 Share Posted July 29, 2008 I did a search for this and saw a lot of people asking similar questions, but all the ones that were solved seemed to have no replies. I don't get it. Anyway... real basic question: in my main folder i have my header.php, footer.php, css file and a folder called content in the content folder I have a template that has an include to ../header.php etc is there a way to make the include look at the things it refers to relative to itself rather than relative to the page that includes it? thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/ Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 r u looking for something like this.. http://www.modwest.com/help/kb5-98.html Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602641 Share on other sites More sharing options...
Zeradin Posted July 29, 2008 Author Share Posted July 29, 2008 i don't have access to my php.ini file i'm looking for something i can put in the footer or in each page that allows the include to look for files from where it is Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602666 Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 you can use string set_include_path ( string $new_include_path ) in your case set_include_path ("./") Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602670 Share on other sites More sharing options...
Zeradin Posted July 29, 2008 Author Share Posted July 29, 2008 for some reason I can't get it to work. I read in thephp manual that this sets the location of the include for the duration of the script so i'd put it in the header and footer... that didn't work... i also moved it to the template before the include calls. also, i messed around with making the path './', '../' '' '/' here's the script i'm currently using, the only one that doesn't generate tons of errors. sorry i'm so slow the template file has: <?php $page=array(); $page['title'] = 'TEMPLATE'; set_include_path('../'); include('hypheader.php'); ?> and <?php set_include_path('../'); include('../hypfooter.php'); ?> the header and the footer don't have anything different in them right now. getting closer at least. Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602708 Share on other sites More sharing options...
wildteen88 Posted July 29, 2008 Share Posted July 29, 2008 Use $_SERVER['DOCUMENT_ROOT'] instead. set_include_path is not what you need. Eg: include $_SERVER['DOCUMENT_ROOT'] . '/hypheader.php' PHP will always include hypheader.php from the root of your website, no matter how far down the directory tree the include command is taking place. Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602911 Share on other sites More sharing options...
Zeradin Posted July 29, 2008 Author Share Posted July 29, 2008 well.. that got it to load the header, but the header is still trying to load things from where the page is, not where the header is located.... basically i get a blank page aside from some stuff in the footer that randomly works. Why? Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602927 Share on other sites More sharing options...
Jabop Posted July 29, 2008 Share Posted July 29, 2008 <?php define("SERVER_ROOT", $_SERVER['DOCUMENT_ROOT']); include(SERVER_ROOT."/folder/blah/file.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602933 Share on other sites More sharing options...
Zeradin Posted July 29, 2008 Author Share Posted July 29, 2008 <?php define("SERVER_ROOT", $_SERVER['DOCUMENT_ROOT']); include(SERVER_ROOT."/folder/blah/file.php"); ?> <?php define("SERVER_ROOT", $_SERVER['DOCUMENT_ROOT']); include(SERVER_ROOT."/thehyp/hypheader.php"); ?> still loads the header, but the header doesn't load any of the images. Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-602961 Share on other sites More sharing options...
Zeradin Posted July 30, 2008 Author Share Posted July 30, 2008 bump? =( Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-603299 Share on other sites More sharing options...
MasterACE14 Posted July 30, 2008 Share Posted July 30, 2008 show the code for hypheader.php Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-603354 Share on other sites More sharing options...
Zeradin Posted July 30, 2008 Author Share Posted July 30, 2008 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $page['title']?></title> <link href="cssface.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="favicon.ico"> <!-- Fix IE. Hide from IE Mac \*/ * html ul li { float: left; } * html ul li a { height: 1%; } /* End */ --> </head> <body topmargin="0" text=#FFFFFF link=#00CCCC alink=#a70000> <!-- menu --> <div id="header"> <img src="images/header.jpg" border="0" usemap="#Map" /> <map name="Map" id="Map2"> <area shape="rect" coords="774,94,847,119" href="contact.php" alt="click here to send us hate mail...or other such junk" /> <area shape="rect" coords="699,96,756,118" href="links.php" alt="click here to view links to other sites" /> <area shape="rect" coords="344,97,411,120" href="articles.php" alt="click here to read articles on various topics" /> <area shape="rect" coords="110,100,158,119" href="index.php" alt="click to access news section" /> <area shape="rect" coords="185,98,311,121" href="http://www.hypboard.com" alt="click here to access the message board" /> <area shape="rect" coords="438,95,489,121" href="focus.php" alt="click here to read in-depth focus articles" /> <area shape="rect" coords="519,96,591,120" href="reviews.php" alt="click here to read reviews" /> <area shape="rect" coords="617,97,674,119" href="media.php" alt="click here to access media" /> </map> <map name="Map" id="Map"> <area shape="rect" coords="699,96,756,118" href="links.php" alt="click here to access media" /> <area shape="rect" coords="344,97,411,120" href="focus.php" alt="click here to read focus articles" /> <area shape="rect" coords="110,100,158,119" href="index.php" alt="click to access news section" /> <area shape="rect" coords="185,98,311,121" href="http://www.hypboard.com" alt="click here to access the message board" /> <area shape="rect" coords="440,94,491,120" href="focus.php" alt="click here to read focus articles" /> <area shape="rect" coords="519,96,591,120" href="reviews.php" alt="click here to read reviews" /> <area shape="rect" coords="617,97,674,119" href="media.php" alt="click here to access media" /> </map> <!-- menu ends --> Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-603453 Share on other sites More sharing options...
Zeradin Posted July 31, 2008 Author Share Posted July 31, 2008 Anyone? I don't mean to keep bugging you but I'd really like to get this to work, it'd really clean up my website. Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-604705 Share on other sites More sharing options...
Zeradin Posted August 1, 2008 Author Share Posted August 1, 2008 Sorry, I promise this is the last time I bump things... then I'll try another forum hahah. I just really want to fix this so I can make the structure of my site not a piece of crap. Quote Link to comment https://forums.phpfreaks.com/topic/117166-different-include-problem/#findComment-605571 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.