OAFC_Rob Posted June 16, 2011 Share Posted June 16, 2011 Okay I posted the other day got some answers, but still have pathway issues. I am getting the following error: Warning: require_once(/innovationation1/commonResources/includes/headerArea.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\innovationation1\newsPages\newsArticles.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '/innovationation1/commonResources/includes/headerArea.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\innovationation1\newsPages\newsArticles.php on line 2 It is basically not finding the correct pathway, when I go into a sub-directory with a URL like this; http://localhost/innovationation1/newsPages/newsArticles.php This is my current require_once statement that is load the dbConnection class. I have tried removing the first bit "/innovationation1", as well as a number of other things are suggestions how to fix this? <?php require_once '/innovationation1/commonResources/dbConnection/dbConnection.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/ Share on other sites More sharing options...
fugix Posted June 16, 2011 Share Posted June 16, 2011 where is the file that you are including your require_once() located? Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230486 Share on other sites More sharing options...
PFMaBiSmAd Posted June 16, 2011 Share Posted June 16, 2011 A leading / on a file system path refers to the root of the current hard disk. You can use $_SERVER['DOCUMENT_ROOT'] to get the file system path to your document root folder, then concatenate the rest of the path to your file to that value to arrive at an absolute file system path. Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230488 Share on other sites More sharing options...
OAFC_Rob Posted June 16, 2011 Author Share Posted June 16, 2011 The pathway in the terms of when it's stored on my computer is: C:xampp/htdocs/innovationation1/commonResources/dbConnection/dbConnection.php I was using $_SERVER["DCOUMENT_ROOT"], but this was presenting issues with <a href=""> </a> links and someone advised me not to use them for normal links so I took them out of the site completely. So was that correct? Or does is it different in the terms of require_once? The dbConnection.php require_once is used within headerArea.php which should be the same pathway location thorughout the site, and it works fine on a the top level ie no sub folders, but once we get into them the issues start happening. Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230490 Share on other sites More sharing options...
PFMaBiSmAd Posted June 16, 2011 Share Posted June 16, 2011 Links are URL's, not file system paths. Include/require statements use file system paths to include a file through the file system. Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230491 Share on other sites More sharing options...
fugix Posted June 16, 2011 Share Posted June 16, 2011 The pathway in the terms of when it's stored on my computer is: C:xampp/htdocs/innovationation1/commonResources/dbConnection/dbConnection.php I was using $_SERVER["DCOUMENT_ROOT"], but this was presenting issues with <a href=""> </a> links and someone advised me not to use them for normal links so I took them out of the site completely. So was that correct? Or does is it different in the terms of require_once? The dbConnection.php require_once is used within headerArea.php which should be the same pathway location thorughout the site, and it works fine on a the top level ie no sub folders, but once we get into them the issues start happening. links have absolutely nothing to do with file system paths, using $_SERVER['DOCUMENT_ROOT'] as PFM said should be sufficient Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230494 Share on other sites More sharing options...
OAFC_Rob Posted June 16, 2011 Author Share Posted June 16, 2011 So would it be like require_once ("".$_SERVER["DOCUMENT_ROOT"]."commonResources/includes/headerArea.php"); Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230496 Share on other sites More sharing options...
OAFC_Rob Posted June 16, 2011 Author Share Posted June 16, 2011 Changed it to require_once($_SERVER["DOCUMENT_ROOT"]/innovationation1/blah/blah.php); Realised I didn't need the "". bit at the start Quote Link to comment https://forums.phpfreaks.com/topic/239542-pathway-issues-again/#findComment-1230512 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.