My site is not doing searches! I could not figure out how to do queries through the search box, I try to access the cars in the database and it brings me the following error:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/u374984363/public_html/newcars/functions.php on line 61
My codes:
functions.php :
function buscarCarros($conexao, $nome){
$carro = array();
$conexao = mysqli_connect('mysql.hostinger.com.br','u374984363_ozzy','******', 'u374984363_ncars');
$query = "select * from carros where nome = {$carro}";
$resultado = mysqli_query($conexao, $query);
while ($carros = mysqli_fetch_assoc($resultado)) {
array_push($carro, $carros);
}
return $carro;
}
result_pesquisa.php :
<?php
include('menu.php');
include('conecta.php');
include('functions.php');
$carro = buscarCarros($conexao, $nome);
foreach ($carro as $carros) :
$carros['nome'];
?>
menu.php :
<nav class="twelve columns">
<ul class="menu">
<li class="menu-item"><a href="index.php">Home</a></li>
<li class="menu-item"><a href="comprar.php">Comprar</a></li>
<li class="menu-item"><a href="">Vender</a></li>
<li class="menu-item"><a href="">Contato</a></li>
</ul>
<form id="searchbox" action="result_pesquisa.php" method="POST">
<input type="text" class="search-top remove-bottom" name="pesquisas" placeholder="Qual carro você procura?">
<!-- <a href="javascript:document.getElementById('searchbox').submit();"> -->
<a href="result_pesquisa.php"><span class="icon-top icon-search"></span></a>
</form>
</nav>