I can not connect to the database

0

Hello, I'm studying php, but when it comes to connecting to DB, it does not connect at all, the bank names are correct, I've imported the bank, and does not anyone know what it can be? >

Connection to the Database

<?php

   /**
  * classe que trata de conexao com o BD e operações
   */
   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    = 'imob';


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

}


/**
*
* @param type $sql -  passo a minha sql
  */
   public function ExecSQL($sql){

   $this->query =  mysql_query($sql, $this->link) or die(mysql_error());


}

 /**
 *
 * @return type -   retorna a lista de registros
 */
    public function ListarDados(){



            $this->lista = mysql_fetch_assoc($this->query);

    return $this->lista;


}

   /**
  *
    * @return type -  retorna a contagem dos registros s query
    */

public function TotalRegistros() {

    return mysql_num_rows($this->query);

}

  }
    
asked by anonymous 08.02.2018 / 04:04

0 answers