dawirick Posted June 1, 2010 Share Posted June 1, 2010 IIS :'( php 4.4.2 (it's what i'm stuck with) I am working on a three column site (internal corprate site) Header Menu LeftCol = SubMenu CenterCol = Content RightCol = RotatingContent Footer I use the Menu to include() subMenu and Content (no problem). I have a define('SITE_PATH', 'www.my/site/root/); $server = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $base = "/bmet"; define('SITE_PATH',substr("$server",0,strpos($server,$base)+strlen($base)) I can echo(SITE_PATH); no problem. My problem is trying to update the Content portion from the SubMenu using include(SITE_PATH.'path/to/include); It doesn't include...I get the lovely "Warning...failed to open stream: No such file or directory... If I enter the path directly into the address bar, *BOOM* the page appears. So I know the path is correct. Why isn't it working? I'm addressing directly from the site root, not relative. EXAMPLE EXAMPLE EXAMPLE EXAMPLE EXAMPLE Menu selection = Forms subMenu loads just fine: <?php /* * #leftCol FORMS ($menu) */ ?> <h1 class="boxit center">FORMS MENU</h1> <p class="center"><a href="?page=forms&menu=forms&list=pat">STATUS</a></p> <p class="center"><a href="?page=forms&menu=forms&list=gen">GENERAL USE</a></p> <p class="center"><a href="?page=forms&menu=forms&list=info">INFORMATIONAL</a></p> Content loads fine: <?php /* * #centerCol FORMS */ $pageTitle = "Forms"; ?> <div class="center"><h2>FORMS</h2></div> <div class="center"><h3><a href="docs/pdf/scheduling/holiday2010.pdf" target="_blank">2010 HOLIDAY SCHEDULE</a></h3></div> <?php if (isset($_GET['list'])) $list = $_GET['list']; else $list = "home"; ?> until <div id="forms" class="center"><? include(SITE_PATH."lib/loads/pages/forms/".$list.".php");?></div> then **ERROR** Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 2, 2010 Share Posted June 2, 2010 <? include(SITE_PATH."lib/loads/pages/forms/".$list.".php"); If SITE_PATH is a variable, where's the $? Quote Link to comment Share on other sites More sharing options...
Mchl Posted June 2, 2010 Share Posted June 2, 2010 <? include(SITE_PATH."lib/loads/pages/forms/".$list.".php"); If SITE_PATH is a variable, where's the $? It's not a variable. define('SITE_PATH',substr("$server",0,strpos($server,$base)+strlen($base)) dawirick: how does the SITE_PATH look like? Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 2, 2010 Share Posted June 2, 2010 Ah completely overlooked that line. Thanks. Do as he says take a look and see if it looks as it should then. I'd say most likely something in your constant is causing it then as Mchl points out. Quote Link to comment Share on other sites More sharing options...
dawirick Posted June 2, 2010 Author Share Posted June 2, 2010 SITE_PATH = www.site/root/bmet/testing/update/ (intranet site) echo (SITE_PATH); = correct complete URI for site root Like I said eralier, I can copy the URI directly out of the error and paste it into the address bar and the referenced page loads just fine. All three columns of base page load the same, dependant on the variable ($page (centerCol), $menu (leftCol), or $ad (rightCol))... if(isset($_GET['menu'])){ $menu = $_GET['menu']; }else{ $menu = 'home'; } if($leftCol != $menu){ include(MENU_LOAD.$menu.'.php'); $leftCol = $menu; } Primary menu link calls "index.php?page=library&menu=library&ad=fda" or whatever depending on what is to be included in the various portions of the page. The various XXXX_LOAD refernces (i.e. PAGE_LOAD, MENU_LOAD, ADS_LOAD) are defined as relative references ... define('PAGE_LOAD', 'lib/loads/pages/'), etc... and work just fine. The problem is when I try to include() another *.php file using a literal reference ... include(SITE_PATH.yada/yada/yada) The if($XXX != YYY) statement stops that portion of the page from being reloaded if nothing has changed. A picture is worth a thousand words (see attachments)... openingScreen loads perfectly... FormsPage, main area loads fine except for the include() area. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 2, 2010 Share Posted June 2, 2010 Just for curiosity sake have you tried hard coding a static include? I assume that this then should work since copying the uri works directly in the address page. Or try a urlencode on it just for the hell of it, doubt that'll work unless you've some characters in there it's trying to parse but wth try anything right. <div id="forms" class="center"><? include("../whatever/lib/loads/pages/forms/B_list.php");?></div> Quote Link to comment Share on other sites More sharing options...
dawirick Posted June 2, 2010 Author Share Posted June 2, 2010 Hardcoding the URI does not make a difference. However, if I place the directory of the load files within the primary directory and use a relative reference...no problem. (i.e. include('forms/'.$list.'.php'); as opposed to include(SITE_PATH.'/lib/loads/pages/forms/'.$list.'.php'); ) This doesn't answer my question though...shouldn't I be able to load a literal reference? Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 2, 2010 Share Posted June 2, 2010 Yeah you should that's why I asked to be sure it wasn't a bug elsewhere causing the issue... Maybe the constant in this case is having issues... Hmm try dropping the constant into a variable and within the include use that variable. (again I doubt this should make a difference... but then again I've seen stranger things with php running on a windows server too. $temp_const = constant("SITE_PATH"); include($temp_const.'/lib/loads/pages/forms/'.$list.'.php'); Quote Link to comment Share on other sites More sharing options...
dawirick Posted June 2, 2010 Author Share Posted June 2, 2010 Tried your suggestion...no difference. I get so tired of trying to appease MS products... Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 2, 2010 Share Posted June 2, 2010 Tried your suggestion...no difference. I get so tired of trying to appease MS products... Ha isn't that the truth... try working with sharepoint & thirdparty software sometime because someone thought it was a good idea instead of using a program language to build it. Maddening... At any rate... sorry I couldn't be more helpful. Hmmm, but maybe bumping this, this many times someone else will suggest something that's more advanced then I am hopefully. Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted June 2, 2010 Share Posted June 2, 2010 is www.site the name of the directory? It's looking for the file "./www.site/root/bmet/testing/update/...", not pulling the URL "http://www.site/root/bmet/testing/update/" Quote Link to comment Share on other sites More sharing options...
marcus Posted June 2, 2010 Share Posted June 2, 2010 Your site path should be an actual path leading on your server, not a URL. Just define the path yourself define(SITE_PATH,'/home/user/www/'); Quote Link to comment Share on other sites More sharing options...
dawirick Posted June 2, 2010 Author Share Posted June 2, 2010 is www.site the name of the directory? It's looking for the file "./www.site/root/bmet/testing/update/...", not pulling the URL "http://www.site/root/bmet/testing/update/" Your site path should be an actual path leading on your server, not a URL. Just define the path yourself define(SITE_PATH,'/home/user/www/'); OY VAY! . Okay! I think that answers my question Yes, I am trying to reference a URL. My problem with referencing the "root directory" is I am operating out of a mapped directory (not in the actual www directory, not even on the same server). Guess I'm stuck with relative references ONLY (unless someone has a creative suggestion). Thanks to all for your help! Quote Link to comment Share on other sites More sharing options...
dawirick Posted June 2, 2010 Author Share Posted June 2, 2010 ...try working with sharepoint... Been there, done that. PAIN IN THE A$$! Quote Link to comment 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.