1

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.

8
  • this might help you : stackoverflow.com/questions/27023454/… Commented Nov 26, 2015 at 7:46
  • How is that file actually called that implements the class 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). Commented Nov 26, 2015 at 7:50
  • @krish thanks but didn't help Commented Nov 26, 2015 at 8:02
  • @arkascha the file is called DB_Functions.php and the class is called DB_Functions. I tried different variations on the path but I don't think that is it because non class files work fine. Commented Nov 26, 2015 at 8:05
  • You need the line require_once 'DB_Functions.php'; if the file is located in the same folder as the including script, as you claim. Commented Nov 26, 2015 at 8:15

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

That's what I thought but it doesn't work. The weird thing is non class files work fine so I don't think its a path problem
Ok guys, it was a problem with the file name I just couldn't see it no matter how hard I looked. Came back a few days later and it just stood out.. guess I needed a break.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.