Problemas en buscador
Estimado,
Tengo el siguiente problema: he creado un buscador direccionado a la tabla
dato_empresa
Con dos paginas una se llama:
---------------------------------------------------------
buscar.php
--------------------------------------------------------
<html>
<meta
http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<body>
<form method="POST"
action="recibe.php">
<strong>Palabra
clave:</strong> <input type="text" name="T1" size="30"><br><br>
<input type="submit"
value="Buscar" name="buscar">
</form>
</body>
</html>
Y la otra
Recibe.php
<html>
<meta
http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<body>
<?php
if (isset($buscar)){
echo "Debe especificar una cadena a buscar";
echo "</html></body> \n";
exit;
}
include("conexión.php");
$result = mysql_query("SELECT *
FROM dato_empresa WHERE empresa LIKE '%$buscar%' ORDER BY empresa ,
$conexión");
if ($row = mysql_fetch_array($result)){
echo "<table border = '1'> \n";
//Mostramos
los nombres de las tablas
echo "<tr> \n";
while ($field =
mysql_fetch_field($result)){
echo
"<td>$field->empresa</td> \n";
}
echo "</tr> \n";
do {
echo "<tr> \n";
echo
"<td>".$row["id_empresa"]."</td> \n";
echo
"<td>".$row["empresa"]."</td> \n";
echo
"<td>".$row["dirección"]."</td> \n";
echo
"<td>".$row["teléfono"]."</td> \n";
echo "<td><a
href='mailto:".$row["mail"]."'>".$row["mail"]."</a></td>
\n";
echo "</tr> \n";
} while ($row = mysql_fetch_array($result));
echo "</table>
\n";
} else {
echo "¡
No se ha encontrado ningún registro !";
}
?>
</body>
</html>
El problema
es que me da los siguientes errores:
Notice:
Undefined variable: buscar in C:\wamp\www\sants\recibe.php on line 16
Warning:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in
C:\wamp\www\sants\recibe.php on line 18
De
antemano Gracias y saludos