include(C:\xampp\htdocs\website\db\u connection\dbconnection.php):无法打开流:没有这样的文件或目录

include(C:\xampp\htdocs\website\db\u connection\dbconnection.php):无法打开流:没有这样的文件或目录,php,windows,xampp,Php,Windows,Xampp,我知道以前也有类似的问题,但我已经尝试了这些帖子中的所有建议,没有任何东西对我有效。我尝试设置路径,更改文件的位置,确保权限适用于windows中的文件,但什么都没有。我正在尝试运行一个php文件,其中包含打开另一个php文件的代码,以便获得连接,但我所做的一切都会引发相同的错误: 警告:include(C:\xampp\htdocs\website\db\u connection\dbconnection.php):无法打开流:第11行的C:\xampp\htdocs\website\db\u

我知道以前也有类似的问题,但我已经尝试了这些帖子中的所有建议,没有任何东西对我有效。我尝试设置路径,更改文件的位置,确保权限适用于windows中的文件,但什么都没有。我正在尝试运行一个php文件,其中包含打开另一个php文件的代码,以便获得连接,但我所做的一切都会引发相同的错误:

警告:include(C:\xampp\htdocs\website\db\u connection\dbconnection.php):无法打开流:第11行的C:\xampp\htdocs\website\db\u connection\index.php中没有此类文件或目录

 <?php set_include_path('C:\\xampp\htdocs\website\db_connection'); ?>
 <?php 

 include('C:\\xampp\htdocs\website\db_connection\\dbconnection.php'); 
 ?>
 </head>
 <body>
 <?php
 if(isset($_POST['save'])){
    $sql = "INSERT INTO website (id, filelocation)
    VALUES ('".$_POST["id"]."','".$_POST["filelocation"]."')";

    $result = mysqli_query($conn,$sql);
 }

?>
警告:include():无法打开C:\xampp\htdocs\website\db\u connection\dbconnection.php以将其包含在C:\xampp\htdocs\website\db\u connection.php的第11行中(include\path='C:\xampp\htdocs\website\db\u connection\index.php')

 <?php set_include_path('C:\\xampp\htdocs\website\db_connection'); ?>
 <?php 

 include('C:\\xampp\htdocs\website\db_connection\\dbconnection.php'); 
 ?>
 </head>
 <body>
 <?php
 if(isset($_POST['save'])){
    $sql = "INSERT INTO website (id, filelocation)
    VALUES ('".$_POST["id"]."','".$_POST["filelocation"]."')";

    $result = mysqli_query($conn,$sql);
 }

?>

那怎么办

include('dbconnection.php');
仅当两个文件位于同一文件夹中时

我认为您不需要
set\u include\u path

如果
index.php
website
文件夹中,您可以使用

include('db_connection/dbconnection.php');

好的,我让它工作了,不知道出了什么问题,我只是重新复制了路径和文件名,它工作了。

检查路径和权限soutput
var\u dump(文件存在('C:\\xampp\htdocs\website\db\u connection\\dbconnection.php'),是否可读('C:\\xampp\htdocs\website\db\u connection\\dbconnection.php')我检查了路径和权限,它们都是正确的我现在不在我的计算机上,但我会在我回到我的计算机时上传输出好的,所以我运行了代码,它说没有我不理解的文件,因为它显示在我的计算机上,我三次检查了权限,它们都很好。我甚至试着允许完全访问,什么也不允许。好的,我成功了,不知道出了什么问题,我只是再次复制了路径,它成功了,所以我们现在可以关闭它。好的,谢谢,我会尝试第二个,我没有考虑使用它,我尝试了第一个代码。我之所以使用include路径,是因为在一个回答中,有人说将其更改为文件所在的文件夹是可行的。