0
I have the following directory tree:
.var
..|--www
......|--site
..........|--index.php
..........|--all
..............|--controller
..................|--conexao.php (classe)
..............|--model
..................|--bo
..................|--vo
..................|--dao
.....................|--prioridade_dao.php (classe)
Pretty extensive beauty, the problem is this: It includes the priority class_dao.php inside index.php (so far so good) if I "NO" put no include in the prioritity_dao.php appear things when viewing the page, now if I put any include in the priority class_dao.php does not appear anything else. I’ve tried to:
include ('../../controller/conexao.php');
include '../../controller/conexao.php';
include ("../../controller/conexao.php");
include "../../controller/conexao.php";
include $_SERVER['DOCUMENT_ROOT']."/all/controller/conexao.php";
Follows priority class_dao.php:
<?php
Class PrioridadeDao{
    error_reporting(-1); 
    ini_set('display_errors', 'On');
    include $_SERVER['DOCUMENT_ROOT']."/all/controller/conexao.php";
    $conexao = new Conexao();       
    public function __construct(){
    }
    public function teste(){
        echo "Chega aqui sim";
    }
    public function selectAll(){
        echo "<br />CHEGA AQUI?";
        if(!$conexao->conecta()){
            exit;
        } else {
            $result = pg_query($conexao->conecta(), "SELECT * FROM prioridade");
            while ($consulta = @pg_fetch_array($result)){
                echo $consulta['nivel']." ".$consulta['nome'];
            }
            $conexaoObj->encerra($conexao->conecta());
        }
    }
}
?>
I have also tried with require, all without success. I did a test calling for direct include to conexao.php in index.php and I did it. I’m using methods __construct() empty in the classes, can that be it? Finally I have researched in a lot of places, tested many things and nothing :( if you can help me I will be very grateful.
After all you want to include which file within which file?
– Ricardo
Show priority code_dao.php
– Fabio Cardoso
enables errors in php.ini and puts the error here
– Israel Zebulon
I want to include the.php connection within the priority_dao.php
– Luan G. C. Rodrigues
Place this at the beginning of the priority file_dao.php:
error_reporting(-1);
ini_set('display_errors', 'On');– Fabio Cardoso
Use absolute Path instead of relative Path.
– Williams
@Luangabrieldacostarodrigue I edited my answer.
– Ricardo
Put include inside some method, or outside the class
– KaduAmaral
Fabio changed the post. $_SERVER['DOCUMENT_ROOT'] prints this exactly: /var/www/ticketdbx/public_html right where I needed it.
– Luan G. C. Rodrigues
@Luangabrieldacostarodrigue to notify the user, put a@ in front of his name. And use the answer space only to answer questions. I converted your comment here :)
– Math