unable to Include Files php using include

2019-08-01 07:05发布

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?

2条回答
在下西门庆
2楼-- · 2019-08-01 07:55

/ 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.

查看更多
等我变得足够好
3楼-- · 2019-08-01 07:57

You have to make

require(interests/sketching/udis.php)

Without

"/"

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

查看更多
登录 后发表回答