PHP include inconsistently working
I have always had problems with PHP's include function. I'm making a shop website and i've created a shopping cart. I want it in each the sidebar of a few pages so i'm using include.
in the file /public_html/product/index.php on line 37:
include("converter.php");
the file converter.php is at /public_开发者_StackOverflow社区html/include/converter.php
At times it seems to work but most of the time it displays:
Warning: include(converter.php) [function.include]: failed to open stream: No such file or directory in /public_html/product/index.php on line 37
and then
Warning: include() [function.include]: Failed opening 'converter.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3371827/public_html/product/index.php on line 37
Am I missing something about include??
Wrong path. Use this:
include("../include/converter.php");
It might be a directory path issue. try using include_once("../include/converter.php");
or debug further using print getcwd();
and then use chdir();
to set correct the path.
edit: missed the folderpath in your question, fixd
The file your looking for is not (directly or indirectly) under any of the paths listed in your include_path . That's why does not work.
精彩评论