play_ Posted February 13, 2007 Share Posted February 13, 2007 Ok. i have the document root set to = $documentRoot = 'http://localhost/Decay/contests/mmporg2/ you can think of it being just http://localhost if you'd like. doesn't change the problem. [localhost] |__[admin] |--menu.php |__[includes] |--header.php |--index.php under the root folder, i have: a folder called 'admin' (menu.php inside) a folder called 'includes' (header.php inside) a file called index.php in index.php, i include header.php. but from header.php, i include menu.php error: Warning: include() [function.include]: URL file-access is disabled in the server configuration in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 37 Warning: include(http://localhost/Decay/contests/mmporg2/admin/menu.php) [function.include]: failed to open stream: no suitable wrapper could be found in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 37 any thoughts? include() has been giving me a really hard time lately. ps: im using absolute path as the include paremeter ps: if i create an index.php inside the 'admin' folder, i get errors too: arning: include() [function.include]: URL file-access is disabled in the server configuration in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 37 Warning: include(http://localhost/Decay/contests/mmporg2/admin/menu.php) [function.include]: failed to open stream: no suitable wrapper could be found in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 37 pss: 'ini_set('allow_url_fopen', 'on');' does not work also Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/ Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 the code should parsed from the original file path thus if you include menu.php from header.php include it as if were included directly from index.php index.php contents include "header.php"; header.php contents include "menu.php"; have u tried it like that? Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183360 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 "header.php contents include "menu.php";" do you mean include "./admin/menu.php" ? because yes, i have. and it works. the problem, index.php under 'admin' folder will give an error it's simple. i just want include('http://localhost/Decay/contests/mmporg2/admin/menu.php'); (in header.php) to work. i cant believe absolue URLs are giving errors Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183362 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 tried to recreate and not having much success i made this root admin menu.php includes header.php index.php INDEX.PHP <? include "includes/header.php"; ?> HEADER.PHP <? include "admin/menu.php"; ?> MENU.PHP this is the menu and all is well if index.php is in "admin" folder HEADER.PHP <? include "menu.php"; ?> allow_url_fopen can only be altered directly through the ini are you on shared platform, what version php? can you put code of each of files on here? Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183371 Share on other sites More sharing options...
o3d Posted February 13, 2007 Share Posted February 13, 2007 I tried this and it worked. I believe that because the original index.php included header.php, it keeps index.php's folder as the "root". INDEX.PHP ****************************** <?PHP echo "<BR>INDEX.PHP<BR>"; include("includes/header.php"); ?> HEADER.PHP ****************************** <?PHP echo "<BR>HEADER.PHP<BR>"; include("admin/menu.php"); ?> MENU.PHP ****************************** <?PHP echo "<BR>MENU.PHP<BR>"; ?> Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183373 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 right, that's how it works for me I tried this and it worked. I believe that because the original index.php included header.php, it keeps index.php's folder as the "root". INDEX.PHP ****************************** <?PHP echo "<BR>INDEX.PHP<BR>"; include("includes/header.php"); ?> HEADER.PHP ****************************** <?PHP echo "<BR>HEADER.PHP<BR>"; include("admin/menu.php"); ?> MENU.PHP ****************************** <?PHP echo "<BR>MENU.PHP<BR>"; ?> Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183374 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 There's an index.php in both the root folder, and another one under 'admin' dir. PHP 5.2.0 MySQL 5.0.27 running all on my windows box. as for a code of each files, there's alot more to them than that. but the include is the problem. Problems with the solution you provided: "include('./admin/menu.php');" will work fine if vieing index.php under the root folder. however, on the index.php under 'admin' folder, i must use include('../admin/menu.php'); But that is obvious. But gives errors. So im trying to use absolute urls. ps: i appreciate your help Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183377 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 if anyone would like, http://www.decay.nu/help.zip....has all the files. try opening index.php from the root folder. works fine. but if you open the index.php under the admin folder, header.php gives you an error because its not including menu.php Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183379 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 I tried this and it worked. I believe that because the original index.php included header.php, it keeps index.php's folder as the "root". INDEX.PHP ****************************** <?PHP echo "<BR>INDEX.PHP<BR>"; include("includes/header.php"); ?> HEADER.PHP ****************************** <?PHP echo "<BR>HEADER.PHP<BR>"; include("admin/menu.php"); ?> MENU.PHP ****************************** <?PHP echo "<BR>MENU.PHP<BR>"; ?> Right. but the index.php under 'admin' dir will cause errors. Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183381 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 you probably wont like this but heres what i get this is index.php this is header.php (included!) this is menu.php (included!) wait nvm, im retarded im getting it too hang on Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183382 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 in header.php.. include('./admin/menu.php'); <--- works but this doesnt work, why?: include('http://localhost/Decay/contests/mmporg2/admin/menu.php'); error: Warning: include() [function.include]: URL file-access is disabled in the server configuration in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 38 Warning: include(http://localhost/Decay/contests/mmporg2/admin/menu.php) [function.include]: failed to open stream: no suitable wrapper could be found in C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes\header.php on line 38 line 38: include($root . 'admin/menu.php'); Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183384 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 is allow_url_fopen set to on in php.ini local and master? here's my ghetto fix in root index.php $root = 1; in header.php if($root){ include('./admin/menu.php'); }else{ include('menu.php'); } Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183390 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 allow_url_fopen has been on, i just checked. Anyways, yes i realize there are fixes around, but that makes the code look dirty =( And thanks for your solution. Although it works, it's inconvenient since i need to include other files through the site =/ there has to be a solid, consistent way of solving this. still trying to figure out why absolute URLs dont work. Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183391 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 whats the status of allow_url_include Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183399 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 Ok. Found a Solution. (thank god). In header.php, i have this: $fullDirPath = dirname(__FILE__); Because that gets excecuted in header.php, $fullDirPath will always be: C:\Program Files\EasyPHP 2.0b1\www\Decay\contests\mmporg2\includes Therefore, i can work from there. I included menu.php like this: include($fullDirPath . '/../admin/menu.php'); So, for now, this solved. I have a feelings it's gonna comeback to haunt. Thanks all that have helped Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183401 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 whats the status of allow_url_include it was on, the whole time. ;] Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183403 Share on other sites More sharing options...
benjaminbeazy Posted February 13, 2007 Share Posted February 13, 2007 that was gonna be my other fix for ya, but i know thatll come back at ya... Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183404 Share on other sites More sharing options...
play_ Posted February 13, 2007 Author Share Posted February 13, 2007 that was gonna be my other fix for ya, but i know thatll come back at ya... hehe. By the way, if anyone wants to tell me why absolute URLs aren't working, i'll be glad. Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-183408 Share on other sites More sharing options...
play_ Posted February 14, 2007 Author Share Posted February 14, 2007 So, for now, this solved. I have a feelings it's gonna comeback to haunt. ding! Link to comment https://forums.phpfreaks.com/topic/38269-solved-brutal-issues-including-files-include/#findComment-184291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.