unable to Include Files php using include

邮差的信 提交于 2019-12-12 22:22:04

问题


I have a page called index.php which includes a page new_display.php which again includes two pages i.e. say x.php and y.php

The include is working fine on localhost but not on my hosting! The error i am getting is :-

Warning: require(/interests/sketching/udis.php) [function.require]: failed to open stream: No such file or directory in /hermes/bosweb/web054/b548/ipg.pingcampuscom/mysql/interests/sketching/new_display.php on line 154

Fatal error: require() [function.require]: Failed opening required '/interests/sketching/udis.php' (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in /hermes/bosweb/web054/b548/ipg.pingcampuscom/mysql/interests/sketching/new_display.php on line 154

The Directories are :

index.php -> localhost/mysql

new_display.php -> localhost/mysql/interests/sketching/new_display.php ( Included in index.php as /interests/sketching/new_display.php )

then in new_display x.php and y.php are included as

/interests/sketching/x.php

/interests/sketching/y.php

It works all good in localhost but gives error when i publish the pages on the Domain

Does anyone has any idea why isn't this working?


回答1:


/ indicates an absolute path, meaning your script is looking in the root of the filesystem for a directory called interests.

Instead, try just removing that / at the start of your paths, or prepend $_SERVER['DOCUMENT_ROOT'] to them.




回答2:


You have to make

require(interests/sketching/udis.php)

Without

"/"

Because you have to point to the same folder ;).



来源:https://stackoverflow.com/questions/10901993/unable-to-include-files-php-using-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!