Reputation: 21
I was following a demo tutorial but I encountered this error and I fooled everything to the letter so am not sure what to do ...
Warning: include(home.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\shoppingcart\index.php on line 9
Warning: include(): Failed opening 'home.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\shoppingcart\index.php on line 9
This is the index.php file code -
<?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';
?>
Upvotes: 2
Views: 963
Reputation: 8245
First thing to check is that home.php
is in the same folder as index.php
(so they're next to each other).
Remember that the path "home.php"
references a sibling page in the same folder so if the file isn't there, you'll get this error.
On the other hand, if home.php
is not meant to be a sibling of index.php
and so, is located somewhere else in your directory structure, you'll need to update the value that references it's path
Upvotes: 2