Fatal error: Class 'Connection' not found in C: \ xampp \ htdocs \ home.php on line 5

1

I'm having this connection problem with the bank

PHP:

$i = new Conexao();

$f = $imv['imovel_id'];

$i->ExecSQL("select * from imoveis_fotos where foto_imovel = '$f' limit 1");

$foto = $i->ListarDados();

PHP Connection:

class Conexao {

private $host;
private $user;
private $senha;
private $bd;
private $link;
public  $query;
public  $lista;

//private $tabela;

/**
 *funcao construtora que inicia o link caso esteja null
 */
function __construct() {
    if ($this->link == NULL):

        $this->getConexao();    

    endif;


}

/*
 *faz a conexao caso não tenha valores no LINK
 */
public function getConexao() {
    $this->host = 'localhost';
    $this->user = 'root';
    $this->senha = '';
    $this->bd = 'imoveis';


    $this->link = mysql_connect($this->host, $this->user, $this->senha) or die('Erro de conexão');
    mysql_select_db($this->bd, $this->link);
    mysql_set_charset('UTF8', $this->link); 
}

PHP Config:

<?php


function __autoload($class) {

$arquivo = "{$_SERVER['DOCUMENT_ROOT']}/app/{$class}.class.php";

if (file_exists($arquivo)):
    //require_once (Config.php);
    require_once ($arquivo);
else:
    die("<h1>Erro algum arquivo esta faltando</h1>");

endif;
    
asked by anonymous 16.02.2017 / 18:08

1 answer

1

So the problem is in __autoload , which is not working properly. It echo $_SERVER['DOCUMENT_ROOT'] and see what it shows, usually DOCUMENT_ROOT brings up the root of the project which in your case is app . That is, C:\xampp\htdocs\app , then as you wrote /app/{$class}.class.php , the link to the file became C:/xampp/htdocs/app/app/{$class}.class.php

    
16.02.2017 / 20:29