2

I am adding my index.php in public_html and I have a folder named Includes which is also in the public_html folder. Includes folder has a subfolder named PHP which contains a file paths.php.

Now I want to include paths.php file in my index.php file.THe issue that when I am including it by using include function then it is giving me an error in the error log which is:

[24-Jul-2017 18:36:46 UTC] PHP Warning: include(/Includes/php/paths.php): failed to open stream: No such file or directory in /home/latestex/public_html/index.php on line 45

[24-Jul-2017 18:36:46 UTC] PHP Warning: include(): Failed opening '/Includes/php/paths.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/latestex/public_html/index.php on line 45

Can someone please help me how to include paths.php file in my index file properly.

P.S: The project was working fine locally on wamp with the same configuration but in hosting it is giving me an error.

  • You are using an absolute path to the file `/Includes/php/paths.php`, that first `/` is understood as the root of the drive. You should use a relative path, either omitting the first `/` - `Includes/php/paths.php`, or adding the current directory before it, ie `./Includes/php/paths.php` – JimL Jul 24 '17 at 18:52
  • +JimL I have tried all the methods which you have mentioned but all are giving the same type of error which i mentioned in question. – Hasnain Abid Khanzada Jul 24 '17 at 18:56

3 Answers3

1

Try not using "/". Try this. it may work fine..

<?php
    include(includes/php/paths.php);
?>

Make sure the case is exactly matched. Include or include

JaTurna
  • 194
  • 14
0

Try

<?php
    include("Includes/php/paths.php");
?>

or

<?php
    include($_SERVER['DOCUMENT_ROOT']."/Includes/php/paths.php");
?>

Also check for uppercase, lowercase letters and actual names of folder name and file name...

e.g. Include / include / Includes / Includes, php / PHP, path.php/ paths.php etc..

0

Most likely your hosting is using some Unix-like OS ( Debian for example ) and from your question it's clear, that you're running your code on Windows ( since you're using the WAMP package ).

I suppose that the problem is hidden in case sensitivity of those Operating Systems and their file systems. In your question you've told that the "PHP" folder is with capital letters, but in your code it's with small. So from what you've written you can try this:

    <?php
        include("/Includes/PHP/paths.php");
    ?>

or

    <?php
        include("Includes/PHP/paths.php");
    ?>

My advice is always to use small case letters for folders to escape those kind of errors with ease.