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:
- Using include, require_once and require
- Set file and folder permissions to everyone
- with and without class. prefix
- manually setting the include path
- hard coding the entire path
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.
DB_Functions? That file name (path) is what you have to require or include. Also note that on most systems file names and paths are case sensitive. Only MS-Windows works case insensitive on file systems (whyever).require_once 'DB_Functions.php';if the file is located in the same folder as the including script, as you claim.