Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: Includes directory, strucuture, and/or path issue
    primarykey
    data
    text
    <p>Problem is very simple.. It would seem.</p> <hr> <p>Error:</p> <p>Warning: include(includes/navigation.php): failed to open stream: No such file or directory in C:\xampp\htdocs\sub_page\about.php on line 27</p> <p>Warning: include(): Failed opening 'includes/navigation.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\sub_page\about.php on line 27</p> <hr> <p>I am redoing a site. Currently I am splicing it into PHP. Same way I have also ways done. Except this time I am making it more structured. Example of my code.</p> <pre><code>&lt;!-- Start Navigation --&gt; &lt;?php include 'includes/navigation.php'; ?&gt; &lt;!-- End Navigation --&gt; &lt;!-- Start Top Menu --&gt; &lt;?php include 'includes/top_menu.php'; ?&gt; &lt;!-- End Top Menu --&gt; &lt;!-- Start Promo Menu --&gt; &lt;?php include 'includes/pro_menu.php'; ?&gt; &lt;!-- End Promo Menu --&gt; </code></pre> <p>So lets that the file navigation is in includes folder which is located in the root. Lets say that the code above is on the services page which is '2' levels in. Not 1'. Typically i have it only '1' lvl of dir in so simply changing</p> <pre><code>&lt;?php include 'includes/navigation.php'; ?&gt; </code></pre> <p>to this</p> <pre><code>&lt;?php include '../includes/navigation.php'; ?&gt; </code></pre> <p>worked fine. </p> <p>The above code is on the services page which is located at </p> <p>/sub_page/services/services.php</p> <p>If i moved the services.php file from the above dir path to 1 lvl close to root like so</p> <p>/sub_page/services.php</p> <p>and change the path on the include to </p> <pre><code>&lt;?php include '../includes/navigation.php'; ?&gt; </code></pre> <p>it works fine. I need to be able to call the files from anywhere. Does anyone know how to do this? Thanks!</p> <hr> <p>EDIT: Will use the following as an example. I was pulling a path error on this line</p> <pre><code>&lt;?php include 'sub_page/about_us/includes/meta.php'; ?&gt; </code></pre> <p>I was able to use the following instead</p> <pre><code>&lt;?php include __DIR__ . "/includes/meta.php"; ?&gt; </code></pre> <p>to fix it. However if i tried to add or take away a directory level from the path it would again return an error. The same thing will not work for any of the other lines/paths.</p> <p>before</p> <pre><code>&lt;?php include 'includes/navigation.php'; ?&gt; </code></pre> <p>after</p> <pre><code>&lt;?php include __DIR__ . "/navigation.php"; ?&gt; </code></pre> <p>Any idea?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload