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:
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 19Fatal 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.
/
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:
Try just:
You can’t use ‘/../Renderer.php’. It’s either ‘../’ which refers to one folder up or ‘/’ which refers to root directory.
Remove the first slash and try either:
Or
Which one works depends on your file structure.
require_once DRI . ‘/../Renderer.php’;
I am faceing same problem enter image description hereChange your Current version PHP to PHP 5.3