警告:包括(dbconn.php):未能打开流:没有这样的文件或目录

问题描述:

我有一个网站,我有几个问题。我不确定托管公司是否改变了某些内容或网站遭到黑客入侵。我希望这是好的,因为我列出了用户尝试注册该网站时的错误列表。当用户尝试使用搜索功能时也会发生这种情况,但是在搜索功能中,错误出现在顶部,然后搜索结果实际显示在下面。注册页面不显示任何内容,但出现以下错误。警告:包括(dbconn.php):未能打开流:没有这样的文件或目录

Warning: include(dbconn.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 26 

Warning: include(dbconn.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 26 

Warning: include(): Failed opening 'dbconn.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home1/hoapres/public_html/users/register/index.php on line 26 

Warning: include(functions.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 27 

Warning: include(functions.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 27 

Warning: include(): Failed opening 'functions.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home1/hoapres/public_html/users/register/index.php on line 27 

Fatal error: Call to undefined function userText2Web() in /home1/hoapres/public_html/users/register/index.php on line 40 

您的问题是您使用的路径不正确。 请检查你的代码,你必须包括像

include("dbconn.php"); 

的文件,你可以通过这种方式

$fullpath = "http://yourdomain.com/"; 

尝试如果dbconn.php任何文件夹下,然后

$fullpath = "http://yourdomain.com/foldername/"; 

include($fullpath."dbconn.php"); 
+0

包括应该使用的文件路径,而不是URL。 –

无知道你的目录结构很难提供一个精确的答案,但在试图包含文件之前我会做的第一件事是明确地设置你的包含路径。

假设站点根目录(DOCUMENT_ROOT)是/home1/hoapres/public_html,你有用于存储所有叫includes您的包含文件的文件夹,路径将是/home1/hoapres/public_html/includes

<?php 

    set_include_path($_SERVER['DOCUMENT_ROOT'] . '/includes'); 
    if(!realpath(get_include_path())) exit('Bad path'); 

    /* Test to see what files exist perhaps */ 
    print_r(glob(get_include_path() . '/*.*')); 

    /* Can you see the files you expect? */ 
    include 'dbconn.php'; 
    include 'functions.php'; 

?>