Rifts Posted August 16, 2010 Share Posted August 16, 2010 Hey everyone this is really really simple. say my site is www.mywebsite.com in my index page I have this define('PHPSITE_DIR', 'mywebsite'); require_once(PHPSITE_DIR . '/test/hello.php'); I have a folder named test and inside the folder i have hello.php but when i go to www.mywebsite.com i get Warning: require_once(mywebsite/test/hello.php) [function.require-once]: failed to open stream: No such file or directory in wtf? i'm using godaddy server if that matters Quote Link to comment https://forums.phpfreaks.com/topic/210814-im-tired-and-missing-somethings-or-my-sever-is-messed-up/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 16, 2010 Share Posted August 16, 2010 require/include expects a correct file system path. You can either use an absolute file system path, a relative path (relative to the main page that was requested), or you can make use of the include_path and let php search for the file. An absolute file system path would typically use $_SERVER['DOCUMENT_ROOT'] to get the absolute path of your document_root folder, then append the path and file name of the file you want to require/include. A relative path starts with either a leading .. or ., such as ../some_folder/some_file.php Using the include_path, you just list the bare file name, such as require('some_file.php') and php will search in the include_path to find the file. The include_path setting typically has a dot . as the first entry so that the current folder will be searched first. Quote Link to comment https://forums.phpfreaks.com/topic/210814-im-tired-and-missing-somethings-or-my-sever-is-messed-up/#findComment-1099687 Share on other sites More sharing options...
tomtimms Posted August 16, 2010 Share Posted August 16, 2010 You try using "DOCUMENT_ROOT"? Quote Link to comment https://forums.phpfreaks.com/topic/210814-im-tired-and-missing-somethings-or-my-sever-is-messed-up/#findComment-1099688 Share on other sites More sharing options...
Rifts Posted August 16, 2010 Author Share Posted August 16, 2010 Hey thanks, that is really helpful i'm still pretty new to a lot of this php stuff could you give me a quick example of the include_path I cant seem to figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/210814-im-tired-and-missing-somethings-or-my-sever-is-messed-up/#findComment-1099691 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.