0
I am trying to make a query and return to the user via Ajax and is being displayed the following errors:
Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in line 77 -->
while($experiencia = mysqli_fetch_assoc($resultado)){Warning: Invalid argument supplied for foreach() in line 89 -->
foreach($resultado as $valor){
MY AJAX:
jQuery(document).ready(function($){
  $('.enviar').click(function(){
      $.ajax({           
      url: '<?php bloginfo("template_url") ?>/consulta.php',
      type: 'POST',                    
      data: 'nome=' + $("#nome").val() + '&email=' + $("#email").val() + '&estilo=' + $("#estilo").val() + '&experiencia=' + $("#experiencia").val() + '&altura=' + $("#altura").val() + '&peso=' + $("#peso").val(),      
      error: function(){
          alert('ERRO!!!');
      },
      success: function(data){
          $('#resultado').html(data);
      }               
    });
  });
});
PHP QUERY.
include "banco.php";
function BuscaAlgo($conectar){
$query = "SELECT  USU.usuario,
                 USU.nome,
                 USU.exp,
                 USU.altura,
                 USU.peso,
                 PRAN.exp_ref,
                 PRAN.altura_ref,
                 PRAN.peso_ref,
                 PRAN.tipo_prancha,
                 PRAN.tamanho_prancha, 
                 PRAN.meio_prancha, 
                 PRAN.litragem_prancha       
                  FROM DADOS_USUARIO AS USU 
                       INNER JOIN PRANCHA AS PRAN
                           on USU.exp = PRAN.exp_ref
                            WHERE USU.altura = PRAN.altura_ref
                              AND USU.peso = PRAN.peso_ref
                                ORDER BY USU.usuario DESC LIMIT 1";
$resultado = mysqli_query($conectar,$query);
$retorno = array();
while($experiencia = mysqli_fetch_assoc($resultado)){
  $retorno[] = $experiencia;
}    
return $resultado;
}
$resultado = array();
$resultado = BuscaAlgo($conectar);
foreach($resultado as $valor){
  echo $valor["usuario"]; print(".  .  .  ."); 
  echo $valor["nome"]; print(".  .  .  ."); 
  echo $valor["exp"]; print(".  .  .  ."); 
  echo $valor["altura"]; print(".  .  .  ."); 
  echo $valor["peso"]; print(".  .  .  ."); 
  print("///////");
  echo $valor["tipo_prancha"]; print(".  .  .  ."); 
  echo $valor["tamanho_prancha"]; print(".  .  .  ."); 
  echo $valor["meio_prancha"]; print(".  .  .  ."); 
  echo $valor["litragem_prancha"];  
}   
PHP BANK.:
<?php
$bdServidor = '127.0.0.1';
$bdNome = 'word1';
$bdUsuario = 'root';
$bdSenha = '';
$conectar = mysqli_connect($bdServidor,$bdUsuario, $bdSenha, $bdNome);
if (mysqli_connect_errno($conectar))
{
    echo "Problemas para conectar no banco. Verifque os dados!";
    die();
}
What am I doing wrong?
FOUND THE MISTAKE
The error was in the tables of my bank. Some of them were different from the ones I had stated in SELECT. Problem solved. Both the SELECT how much its return is correct and functional.
I found the error. It was in the tables of my bank, were declared with different names of my
SELECT. Thank you for your willingness to help!– Zkk