Foros del Web » Programando para Internet » PHP »

No encuentro el fallo

Estas en el tema de No encuentro el fallo en el foro de PHP en Foros del Web. No encuentro el fallo en este script: archivo prueba.html Código: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Documento sin t&iacute;tulo</title> </head> <body> <a href="datos.php?buscar=seiya">Seiya</a> </body> </html> ...
  #1 (permalink)  
Antiguo 28/09/2006, 08:16
 
Fecha de Ingreso: junio-2005
Mensajes: 39
Antigüedad: 18 años, 9 meses
Puntos: 0
No encuentro el fallo

No encuentro el fallo en este script:

archivo prueba.html
Código:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<a href="datos.php?buscar=seiya">Seiya</a>
</body>
</html>
archivo datos.php
Código:
<?php 
$buscar=$_GET["buscar"]; 
$link = mysql_connect("localhost", "root"); 
mysql_select_db("sseiya", $link); 
$result = mysql_query("SELECT * FROM personajes WHERE $tipo_datos LIKE \"%$buscar%\" ORDER BY nombre", $link); 
if ($row = mysql_fetch_array($result)){ 
      echo "<table border = '1'> \n"; 
//Mostramos los nombres de las tablas 
echo "<tr> \n"; 
echo "<th>Nombre</th><th>Constelación</th><th>Procedencia</th><th>Categoría</th>";
echo "</tr> \n"; 
do { 
            echo "<tr> \n";  
            echo "<td>".$row["nombre"]."</td> \n"; 
            echo "<td>".$row["constelacion"]."</td> \n"; 
            echo "<td>".$row["procede"]."</td> \n"; 
            echo "<td>".$row["categoria"]."</a></td> \n"; 
            echo "</tr> \n"; 
      } while ($row = mysql_fetch_array($result)); 
            echo "</table> \n"; 
} else { 
echo "¡ No se ha encontrado ningún registro !"; 
}

?>
y me da este error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\Domains\sseiya\datos.php on line 14
(La línea 14 es la que he marcado en negrita.)
__________________
www.bpvradio.com
  #2 (permalink)  
Antiguo 28/09/2006, 08:21
Avatar de weti  
Fecha de Ingreso: abril-2006
Mensajes: 18
Antigüedad: 18 años
Puntos: 0
revisa la consulta de mysql, no lo he mirado a fondo pero fijate si tu campo en la base de datos se llama $tipo_datos, el error puede ser por eso.

un consejo: ante la duda haz despues d la consulta un print $consulta; para ver que la consulta esta bien hecha y toma todos los datos bien.

un saludo, suerte
  #3 (permalink)  
Antiguo 28/09/2006, 08:32
 
Fecha de Ingreso: junio-2005
Mensajes: 39
Antigüedad: 18 años, 9 meses
Puntos: 0
Pues sí, era eso. Muchas gracias.
__________________
www.bpvradio.com
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:32.