Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/04/2013, 09:33
summerblack
 
Fecha de Ingreso: diciembre-2012
Mensajes: 249
Antigüedad: 11 años, 4 meses
Puntos: 2
Duda con mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean gi

Hola chicos, les cuento que tengo una duda sobre como buscar por varios campos digamos por id y ciudad

Primero que todo tengo 2 archivos pedido.php

Código PHP:
Ver original
  1. function mostrarConsulta($busId,$busCiudad){
  2.   $sql = new Mysql;
  3.   $sql->connect();
  4.   $query = "select * from pedidos where Id= $busId and Ciudad=$busCiudad";
  5.   $result = $sql->query($query);
  6.   $sql->close();
  7. if (!$result){
  8. return false;
  9. echo ('Registro no encontrado');
  10. }
  11. else{
  12. return $result;
  13.   }
  14.   }

y busqueda.php

Código PHP:
Ver original
  1. include_once("pedido.php");
  2.  
  3. $p=new Pedido;
  4. $busId = 33;
  5. $busCiudad = 'Medellin';
  6. $lista= $p->mostrarConsulta($busId $busCiudad);
  7. ?>
  8.  
  9. <table style="border:1px solid #ccc; color:#000;width:800px;">
  10. <tr style="background:#3399FF;">
  11. <td>Pedido No.</td>
  12. <td>Ciudad<br/></td>
  13. <td>Fecha </td>
  14. <td>Encargado</td>
  15. <td>Observaciones</td>
  16. <td>Generar PDF</td>
  17. </tr>
  18. <?php
  19.  while($row = mysqli_fetch_array($lista)){
  20.   echo "<tr>";
  21.   echo "<td>".$row['Id']."</td>";
  22.   echo "<td>".$row['Ciudad']."</td>";
  23.   echo "<td>".$row['Fecha']."</td>";
  24.   echo "<td>".$row['Nombres']."</td>";
  25.     echo "<td>".$row['Observaciones']."</td>";
  26.   echo "</tr>";
  27.  }
  28. ?>
  29. </table>

Pues cuando busco solo por Id todo muy bien, y me trae los datos, pero cuando pongo a buscar por id y por ciudad me bota el siguiente error

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\Apache\htdocs\...busqueda.php on line 23 y no entiendo porque, si alguien me puede ayudar muchas gracias!!