Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复文件路径错误?index.php?它从一开始就不起作用,所以我不知道该怎么办_Php_Html_Mysql - Fatal编程技术网

如何修复文件路径错误?index.php?它从一开始就不起作用,所以我不知道该怎么办

如何修复文件路径错误?index.php?它从一开始就不起作用,所以我不知道该怎么办,php,html,mysql,Php,Html,Mysql,我是按照演示教程,但我遇到了这个错误,我愚弄了一切的信,所以不知道该怎么办 警告:include(home.php):无法打开流:第9行的C:\xampp\htdocs\shoppingcart\index.php中没有此类文件或目录 警告:include():在第9行的C:\xampp\htdocs\shoppingcart\index.php中打开“home.php”以包含(include\path='C:\xampp\php\PEAR')失败 这是index.php文件代码- <?p

我是按照演示教程,但我遇到了这个错误,我愚弄了一切的信,所以不知道该怎么办

警告:include(home.php):无法打开流:第9行的C:\xampp\htdocs\shoppingcart\index.php中没有此类文件或目录

警告:include():在第9行的C:\xampp\htdocs\shoppingcart\index.php中打开“home.php”以包含(include\path='C:\xampp\php\PEAR')失败

这是index.php文件代码-

<?php
session_start();
// Include functions and connect to the database using PDO MySQL
include 'functions.php';
$pdo = pdo_connect_mysql();
// Page is set to home (home.php) by default, so when the visitor visits that will be the page they see.
$page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'home';
// Include and show the requested page
include $page . '.php';
?>

首先要检查的是
home.php
index.php
位于同一文件夹中(因此它们相邻)

请记住,路径
“home.php”
引用了同一文件夹中的同级页面,因此如果该文件不在那里,则会出现此错误


另一方面,如果
home.php
不是
index.php
的兄弟,因此位于目录结构中的其他位置,则需要更新引用其路径的值,而不知道应用程序文件结构(所有文件相互关联时),我们不可能知道您需要做什么来解决这个问题。\--shoppingcart |--functions.php |--index.php |--home.php |--products.php |--product.php |--cart.php |--placeorder.php |--style.css \--imgs |--featured-image.jpg |--camera.jpg |--heedphone.jpg |--wallet.jpg |--watch或者现在,我找到了pear文件的位置,只是将文件放在其中的文件中,但这不是最好的解决方案,它仍然没有显示home.page内容。我理解正确,但是,正如您所说,home.php文件是同级文件,它们位于同一位置。index.php基本上是一个路由文件,可以为每个链接连接启动会话的页面我相信因为它们是同级的,并且彼此之间的位置正确,接下来要评估的是路径值是否实际正确。要查找的内容:
$\u GET['page']
,分配后,
$page
的值是多少,以及作为include上的目标输出的
$page..php'
的值是多少?如果页面存在,那么问题很可能是如何在代码中识别它