Jump to content
Fórum Script Brasil
  • 0

Erro mysqli_query() expects parameter 1 to be mysqli, null given in


Question

Estou há dias tentando entender o motivo do erro "mysqli_query() expects parameter 1 to be mysqli, null given in" no meu projeto.

Classe utilizada (arquivo conexao.php):

class Funcoes {
     
    public $servidor = 'localhost';
    public $usuario = 'meu_user';
    public $senha = 'minha_senha';    
    public $bd = 'meu_bd';    
    
    public function cnx()
    {    
        $link = mysqli_connect($this->servidor, $this->usuario, $this->senha, $this->bd);    
        return $link;                
    }

}

Arquivo com o erro:

    include ($_SERVER['DOCUMENT_ROOT']."/_pg/conexao.php"); 
 
     $obj = new Funcoes();
     $link = $obj->cnx();           
           
    function abreLink($descricao) {
        
        $query = mysqli_query($link, "SELECT * FROM links WHERE descricao='$descricao'");    
        
        while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
            $url = $row['link'];        
        }          
        return $url;
    } 
 }

 

Alguém poderia dar uma luz?!

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149411
    • Total Posts
      645902
×
×
  • Create New...