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í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.)