irkevin Posted October 13, 2007 Share Posted October 13, 2007 HI guys, i really need to figure this out im on a windows server, and somehow, when i use include('../functions.php'); it doesn't find the functions.php page!! i have a file name posting.php, it's in a folder, and i need to include the functions file to it.. i also tried include('http://www.mu-anime.com/functions.php'); but it doesn't work... Some people told me to try the code below since im on a windows server include('C:\hshome\tipa-mu\mu-anime.com\functions.php') but i got these warning messages Warning: main(C:\hshome\tipa-mu\mu-anime.com\functions.php) [function.main]: failed to open stream: No such file or directory in C:\hshome\tipa-mu\mu-anime.com\shoutbox\posting.php on line 4 Warning: main() [function.include]: Failed opening 'C:\hshome\tipa-mu\mu-anime.com\functions.php' for inclusion (include_path='.;c:\php4\pear') in C:\hshome\tipa-mu\mu-anime.com\shoutbox\posting.php on line 4 What should i do? Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 Huh, no one can solve this? ??? Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 in the code, i should use include('../functions.php'); but it's not working on the windows platform..but on linux yes.. but i need it to work on windows platform too Really, no one? :'( Quote Link to comment Share on other sites More sharing options...
RobertSubnet Posted October 13, 2007 Share Posted October 13, 2007 I work with an IIS server. When I use an include or require_once, I put in the directory path from the main folder along with the file I need like this: include ('./includes/header.html'); require_once('./includes/mysql_connect.php'); //connect to the db Hope this helps. ~Robert Quote Link to comment Share on other sites More sharing options...
Barand Posted October 13, 2007 Share Posted October 13, 2007 In your php.ini file there is setting include_path = put the file to be included in one of the folders specified in that setting Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 apart from php.ini is there any other thing i can try? if there is, plz help me out Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 13, 2007 Share Posted October 13, 2007 Are you sure functions.php exists in C:\hshome\tipa-mu\mu-anime.com\ make sure you have spelt the name correctly. Also you can use relative paths in Windows boxes too. You don't have to specify absolute paths. Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 yes im positive it exists.. what kind of relative path are you refferring to? im using this include('C:\hshome\tipa-mu\mu-anime.com\functions.php'); and it doesnt work Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 13, 2007 Share Posted October 13, 2007 The ".." means go back one directory. Is the file located in the same directory as your source or one level up from your source. if it's in the same directory, you should use either: <?php include('./functions.php'); ?> or <?php include('functions.php'); ?> Ken Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 the functions.php page resides where my index.php is.. and the other page im trying to use is in a folder this is getting me maaaad.. any other idea? the on u gave me didn't work ken Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 13, 2007 Author Share Posted October 13, 2007 No one? Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 someone has another idea for this?? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 If this the functions.php page resides where my index.php is.. is true then <?php include('functions.php'); ?> from the index file will work.. if its not from the index.. then readup on Relative Paths.. Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 but the page im including the functions.php page is in another directory,, which mean i have to use include('../functions.php'); which is actually not working Why is it so :S Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 Show use.. ie Index.php function.php Tests --test1.php --test2.php --test3.php --Old ----test1.php Docs --doc1.doc etc from that example test1.php would include function.php like this include "../function.php"; Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 well, the functions.php page resides where the index.php is.. I have a folder name Shoutbox and inside the folder there is a page name posting.php. Now, inside the posting.php, i need to include the functions.php, which is in the root directory! even if i use include "../functions.php"; it doesn't include the file correctly... This is quite bizzare !! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 so index.php functions.php Shoutbox --posting.php OK if include "../functions.php"; doesn't work try this include dirname(__FILE__)."/../functions.php"; Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 Nopes it doesn't work .. and i wonder if there is a solution for this also the code you gave me, it's basically this C:\hshome\tipa-mu\mu-anime.com\shoutbox\functions.php, but it should not look for the functions.php page in the shoutbox folder.. the link should be like this C:\hshome\tipa-mu\mu-anime.com\functions.php .. See what i mean? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 worth a shot.. try include dirname(__FILE__)."\..\functions.php"; or include realpath(dirname(__FILE__) . "/functions.php"); or include realpath(dirname(__FILE__) . "\functions.php"); Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 Nopes ... won't work.. Wow.. just a simple include is driving us crazy like this :s Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 what does this mean? (include_path='.;c:\php4\pear') ?? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 lets try something new 2 files, upload into same folder and run test1.php <?php echo "Hello "; include "test2.php"; ?> <?php echo "World"; ?> if that works (and it should) create a folder called "TEST" and move test2.php into it, and change test1.php to <?php echo "Hello "; include "TEST/test2.php"; ?> try that.. thats should also work.. NOW create a new file called "test3.php" in the same place as "test1.php" <?php echo "Woohoo"; ?> and update test2 to <?php echo "World"; include "../test3.php"; ?> Lets see what happens Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 when i go to page test2.php, instead of showing World Woohoo, i get this World Warning: main(../test3.php) [function.main]: failed to open stream: No such file or directory in C:\hshome\tipa-mu\mu-anime.com\test\test2.php on line 3 Warning: main() [function.include]: Failed opening '../test3.php' for inclusion (include_path='.;c:\php4\pear') in C:\hshome\tipa-mu\mu-anime.com\test\test2.php on line 3 And btw, my PHP include path is .;c:\php4\pear ! what does that mean?? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 okay.. lets try this <?php echo "World"; include "..\test3.php"; ?> also on test1.php add this echo $_SERVER['DOCUMENT_ROOT']; PHP include path, means where it searches for the included files if their not found.. Quote Link to comment Share on other sites More sharing options...
irkevin Posted October 14, 2007 Author Share Posted October 14, 2007 this is the code i added in test1.php <?php echo "Hello "; include "test/test2.php"; echo $_SERVER['DOCUMENT_ROOT']; ?> i get this Hello World Warning: main(.. est3.php) [function.main]: failed to open stream: No such file or directory in C:\hshome\tipa-mu\mu-anime.com\test\test2.php on line 3 Warning: main() [function.include]: Failed opening '.. est3.php' for inclusion (include_path='.;c:\php4\pear') in C:\hshome\tipa-mu\mu-anime.com\test\test2.php on line 3 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.