-1
I’m starting basic API for personal use, but at first I’ve come across a little problem that my eyes didn’t notice the origin:
Warning: mysqli_connect() expects Parameter 1 to be string, Object Given in
Here my connection:
<?php
function BDconecta() {
$con = mysqli_connect("localhost", "root", NULL, "emissor_nfe") or die("Sem conexão ". mysqli_connect_error());
mysqli_set_charset($con, "utf8");
return $con;
}
function BDClose($con) {
mysqli_close($con);
}
?>
And here where I call the connection to the comic that appears the error:
<?php
include_once './conexao/conn.php';
if (!isset($_GET['pg'])) {
echo '<h2>Escolha um Emitente para Começar:</h2><br/>';
$query = ('Select * FROM emitente');
$lista = mysqli_connect(BDconecta(), $query) or die("Um erro na comunicao" . mysqli_connect_error());
$achou = mysqli_num_rows($lista);
if ($achou > 0) {
while ($exibir = mysqli_fetch_array($lista)) {
$id = $exibir['id'];
$fantasi = $exibir['nome_fantasia'];
echo '<table><tr><td>' . $id . '</td><td>' . $fantasi . '</td></tr></table>';
}
echo '<br/><h2><a href="?pg=incluir">CADASTRAR</a></h2>';
}else{
echo '<h2 style="color: red">Nenhum Emitente Cadastrado</h2>';
echo '<br/><h2><a href="?pg=incluir">CADASTRAR NOVO</a></h2>';
}
} else {
$pagina = $_GET['pg'];
switch ($pagina) {
case 'incluir';
include_once './privado/cad_emitente.php';
break;
default:
}
}
?>