0

the last time i ask a question here i ended up solving it myself.. But not his time, been searching hours again till i can't think anymore.. Maybe i can pick your brain.

Here is my problem.

I have an include folder in root directory, inside i have a DB_info.php file which holds $hostname, $user, $password, $DBname. In the same include, there is a folder name subfolder which holds a Dbconnect.php,inside it has a require "../DB_info.php"; and the try{$pdo= new} which conects to the database. With the connected succefully visible on the DBconnect page.

When trying to add a require on the root directory index.php, require "include/subfolder/DBconnect.php";, i get the error saying the the required field require(../DB_Info.php)"Failed to open stream: No such file or directory"

any thoughts?

i keep trying going back on folders, ../include/subfolder/Dbconnect.php, ../../subfolder/Dbconnect.php.

-------EDITED------

With Xander suggestion bellow it lead me to creating a header.php page. Inside i have:

$site['url'] = "http://subscribe.com";

$site['base'] = "{$site['url']}templates/base/"; $site['inclu'] = "{$site['url']}inclu/"; $site['classes'] = "{$site['inclu']}classes/";
define("CreProSion_URL_ROOT", $site['url']);

define("CreProSion_URL_INCLU", $site['inclu']); define("CreProSion_INCLU_CLASS", $site['classes']);

but the above code gives me a 404 error if i view the header.php file, also the DBconnect gives me this error:

PHP Warning: require_once(http://subscribe.com/inclu/classes/DBconnect.php): Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

  • 2
    _"any thoughts?"_ - stating the obvious, your paths are wrong. I can't fathom the folder structure from your description. Post a diagram or screenshot showing the actual folder layout with the root marked and the location of the various PHP files. – Tangentially Perpendicular Jun 29 '23 at 03:21
  • Hey, so you don't encounter these kind of problems in the future, I suggest you either create a custom autoloader, or use composer to autoload clases. For your current issue, in case non of the above worked, you can try to put the full path to `DB_Info.php` in that require. – Xander-Nova Jun 29 '23 at 05:07
  • Hi, thanks Xander for your input. The composer were a very good idea on me searching it, but that would not work in my case due to . The site i'm building , which is also my first. Has an installer which populate the DB_info.php page.. – joestein617 Jun 29 '23 at 22:54

0 Answers0