Problem with include_onde () when calling my db

0

I have this line of code include_once('./config/dbh.inc.php) to include the database to a data upload file but I get this error:

Warning: include_once(./config/dbh.inc.php): failed to open stream: No such file or directory in C:\xampp\htdocs\proyecto-final\idehome-master\componentes\upload\model.php on line 40

Warning: include_once(): Failed opening './config/dbh.inc.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\proyecto-final\idehome-master\componentes\upload\model.php on line 40

I have tried it in a thousand ways and this error keeps coming up. Here I leave the structure of my files:

I hope someone has the solution. Greetings and thanks for the help.

    
asked by MadCode 20.06.2018 в 17:22
source

1 answer

2

If you call ./config/dbh.inc.php from your index.php the route would be correct. If instead you call it from upload/model.php the route should be modified to:

include_once('../config/dbh.inc.php)

The healthiest thing is always to use an absolute route:

include_once(__DIR__.'/../config/dbh.inc.php'); // desde model.php

or

include_once(__DIR__.'/config/dbh.inc.php'); // desde index.php
    
answered by 21.06.2018 / 14:42
source