Reputation: 2939
I am running wamp on windows and am trying to use a php include, however I keep getting errors like so:
Warning: include(class.DB_Functions.php): failed to open stream: No such file or directory in C:\wamp\www\ysc\Clients.php
Warning: include(): Failed opening 'class.DB_Functions.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\ysc\Clients.php
Fatal error: Class 'DB_Functions' not found in C:\wamp\www\ysc\Clients.php
Things I have tried:
Here is one of the files causing the error (on the include statement line)
<?php
include 'class.DB_Functions.php';
$db = new DB_Functions();
$clients = $db->retrieveClients();
echo json_encode($clients);
?>
One of the php files I cannot include
<?php
class DB_Connect {
private $conn;
// Connecting to database
public function connect() {
require_once 'Config.php';
// Connecting to mysql database
$this->conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// return database handler
return $this->conn;
}
}
?>
All files are in the same folder where the PHP files that are not classes work fine, but none of the class php files will include.
Upvotes: 1
Views: 1745
Reputation: 1643
It all depend on your files location. With your require code, I'm sure that if you put all of your PHP file in the same folder (C:\wamp\www\ysc), that error will not happen
Upvotes: 1