警告:include(dbconn.php):无法打开流:没有这样的文件或目录

时间:2015-10-18 10:50:41

标签: php mysql

我有一个网站,我有几个问题。我不确定托管公司是否确实改变了某些内容或该网站遭到黑客入侵。我希望这没关系,因为我在用户尝试注册该站点时列出了错误列表。当用户尝试使用搜索功能时也会发生这种情况,但在搜索功能中,错误显示在顶部,然后搜索结果实际显示在下方。注册页面除了以下错误外不会显示任何内容。

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

2 个答案:

答案 0 :(得分:0)

在不知道您的目录结构的情况下提供精确答案很棘手,但在尝试包含文件之前我要做的第一件事就是明确设置包含路径。

假设网站根目录(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';

?>

答案 1 :(得分:-1)

您的问题包括您使用的路径不正确。 请检查您的代码,其中包含

等文件
include("dbconn.php");

你可以通过这种方式尝试

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

如果dbconn.php在任何文件夹下,那么

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

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