require_once not working on live server

I have a situation where a php line is working fine on localhost but not on live server, even if I have the same file and folder structure.

require_once '/../Renderer.php';

The error I am getting on live server is:

Read More

Warning: require_once(/../Renderer.php): failed to open stream: No
such file or directory in
/home2/attafsir/public_html/balaghatoalquran/production/wp-content/themes/twentyten/Text/Diff/Renderer/unified.php
on line 19

Fatal error: require_once(): Failed opening required
‘/../Renderer.php’
(include_path=’.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear’) in
/home2/attafsir/public_html/balaghatoalquran/production/wp-content/themes/twentyten/Text/Diff/Renderer/unified.php
on line 19

I have spend a lot of time trying to figure out what could be the reasons behind such behaviour, but to no avail, your help is appreciated.

PS: I have verified with my host if PEAR is installed and configured in php.ini, and they confirm it to me. (since the code is using PEAR package)

Solution:
The solution is the accepted answer, but I want to notice though that the problem on live server is resolved but broke the functionning on localhost. This is a temporary solution since the best thing is to have the same code on local and live server. I will be back to post a full solution when I find it. your suggestion are always welcome.

Related posts

Leave a Reply

6 comments

  1. / is the root of the file-system and then you try to go up one level with ... That does not exist so you get an error.

    Are you sure you do not want a relative path?

    If you want it to be relative to the root of the web-server (which is not the root of the file-system unless there is something very wrong), use something like:

    $_SERVER['DOCUMENT_ROOT'] . '/../Renderer.php'
    
  2. Remove the first slash and try either:

    require_once '../Renderer.php';
    

    Or

    require_once '../../Renderer.php';
    

    Which one works depends on your file structure.