Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/12/2010, 11:04
eduardo160
 
Fecha de Ingreso: julio-2010
Mensajes: 523
Antigüedad: 13 años, 9 meses
Puntos: 4
Respuesta: problema en consulta con php mysql

hola mira eso que me diste me da el siguiente error

Error, query failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nombre LIKE '%%' OR apellido LIKE '%%' OR cod LIKE '%%' OR correo' at line 2



anexo todo el codigo nuevamente
Código PHP:
Ver original
  1. <?
  2. include "conexion.php";
  3. include "menu/menu.php";
  4.  
  5.     $dato = $_POST["dato"];
  6.  
  7. $consulta = "SELECT * FROM registro WHERE
  8.   nombre LIKE '%$dato%' OR
  9.   apellido LIKE '%$dato%' OR
  10.   cod LIKE '%$dato%' OR
  11.   correo LIKE '%$dato%'";
  12.  
  13. $result = mysql_query($consulta) or die('Error, query failed'. mysql_error());
  14.  
  15. if(mysql_num_rows($result) == 0)
  16. {
  17.     echo "No se encontraron RESULTADOS <br>";
  18. }else{  
  19. while ($row = mysql_fetch_array($result)){
  20.    
  21.      $_SESSION["nombre"]=$row{'nombre'};
  22.      $_SESSION["apellido"]=$row{'apellido'};
  23.      
  24.      echo $_SESSION["nombre"];
  25.     echo $_SESSION["apellido"];            
  26.  
  27.    
  28. }
  29. }
  30. ?>