1
I’m having this problem connecting 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 Conexão:
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;
What version php?
– Max Rogério
PHP version 5.6.8
– user67057
Avoid using
mysqlbecause it is obsolete, usemysqliorPDO, apparently is trying to include the classConexaowho is inC:\xampp\htdocs\home.php. Which directory is the fileConexao? Inappmsm?– Max Rogério
Yes, this in Connexion
– user67057
I don’t think you understand me... the file
Conexaois in which folder (directory), this error is giving because theincludeorrequireis wrong, need to point to the correct file location.– Max Rogério
C: xampp htdocs app Conexao.class.php
– user67057
So the problem is in
__autoload, that is not working properly. It doesecho $_SERVER['DOCUMENT_ROOT']and see what it shows, normallyDOCUMENT_ROOTbrings up to the root of the project which in your case isapp. That is to say,C:\xampp\htdocs\app, then as you wrote/app/{$class}.class.php, the link to the archive wasC:/xampp/htdocs/app/app/{$class}.class.php– Max Rogério
Thank you very much.
– user67057
Worked? If yes, I will turn the comment in response and you leave with the symbol of best answer (green).
– Max Rogério