Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/12/2010, 18:26
Avatar de alfoner
alfoner
 
Fecha de Ingreso: abril-2009
Mensajes: 146
Antigüedad: 15 años
Puntos: 0
Pregunta error en buscador php mysql en la linea while -- ayuda

Hola, estoy haciendo un bucador que busca en una base de datos, cuando introduzco el texto lo busca perfectamenteme pero al presionar el boton buscar sin introducir ningun texto me sale el siguiente error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\login\prueba.php on line 27


es en la linea de <?php while ($fila=mysql_fetch_array($rst_clientes)){ ?>


aqui esta el codigo, gracias.

<body>
<form id="form1" name="form1" method="post" action="prueba.php">
<p>
<label for="busca"></label>
Busqueda por nombre</p>
<p>
<input type="text" name="busca" id="busca" />
</p>
<p>
<input type="submit" name="buscar" id="buscar" value="Buscar" />
</p>
<p>
<?php
$busca="";
$busca=$_POST['busca'];
mysql_connect("localhost","root","");
mysql_select_db("mibase");
if($busca!=""){
$rst_clientes=mysql_query("SELECT * FROM `clientes` WHERE nombre LIKE '%".$busca."%'");


}
?>

<?php while ($fila=mysql_fetch_array($rst_clientes)){ ?>


<tr>
<td width="724"><table width="721" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="12" bgcolor="#FF6600">&nbsp;</td>
<td width="663" bgcolor="#FF6600"><b><font color='white'><?php echo $fila["localidad"];?></b></td>
</tr>
</table></td>
</tr>
<tr>
<td width="316"><?php echo $fila["nombre"];?></td>
</tr>
</table></td>
</tr>
<p>&nbsp;</p>
<?php
}
?>
</html></p>
</form>
<p>