Buenas,
Estoy haciendo una pagina web para una asociación y me he atascado en un sitio que no se donde arreglarlo. He probado un monton de cosas y todo da error.
Aquí os dejo la pagina en cuestion que es un buscador
<?php
header('Content-Type: text/html; charset=UTF-8');
include ('config.php');
include ('functions.php');
mysql_select_db($db_name,mysql_connect($db_host,$db_user,$db_pass));
validar_hash();
if(isset($_SESSION[$sesion_hash]))
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Asociación Alicantina de Jugger</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="AAJ, Jugger, Alicante, FEJ" />
<meta name="description" content="Pagina privada para la AAJ" />
<meta name="author" content="Asociacion Alicantina de Jugger" />
<meta name="publisher" content="Asociacion Alicantina de Jugger" />
<meta name="copyright" content="Asociacion Alicantina de Jugger" />
<meta name="audience" content="all" />
<meta name="robots" content="all" />
<link rel="stylesheet" type="text/css" href="css.css" />
</head>
<body>
<div id="banner"><img src="imagenes/banner.gif" alt="banner" /></div>
<div id="menuweb"><a href="menu.php">PRINCIPAL</a> - ALTAS - BUSCADOR - <a href="logout.php">SALIR</a></div>
<div id="contenedor">
<div id="contenedor_arriba">PRINCIPAL</div>
<div id="contenedor_medio">
<form name="formulario" method="post" action="buscador.php">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="18%"><strong>NOMBRE</strong></td>
<td width="1%"> </td>
<td width="30%"><input type="text" name="nombre1" /></td>
<td width="25%"><strong>APODO</strong></td>
<td width="1%"> </td>
<td width="23%"><input type="text" name="apodo1" /></td>
<td width="2%"> </td>
</tr>
<tr>
<td><strong>APELLIDO1</strong></td>
<td> </td>
<td><input type="text" name="apellido11" /></td>
<td><strong>APELLIDO2</strong></td>
<td> </td>
<td><input type="text" name="apellido21" /></td>
<td> </td>
</tr>
<tr>
<td><strong>FECHA DE NACIMIENTO</strong></td>
<td> </td>
<td><input type="text" name="fecha1" /></td>
<td><strong>DNI</strong></td>
<td> </td>
<td><input type="text" name="dni1" /></td>
<td> </td>
</tr>
<tr>
<td><strong>EMAIL</strong> </td>
<td> </td>
<td><input type="text" id="email1" /></td>
<td><strong>EQUIPO</strong></td>
<td> </td>
<td><input type="text" name="equipo11" /></td>
<td> </td>
</tr>
<tr>
<td colspan="7"><div align="center"><strong>ORDENAR BUSQUEDA POR:
<select name="criterio">
<option value="nombre_equipo" selected="selected">EQUIPO</option>
<option value="nombre">NOMBRE</option>
<option value="apellido1">APELLIDO1</option>
<option value="apeliido2">APELLIDO2</option>
<option value="apodo">APODO</option>
<option value="fechanacimiento">FECHA</option>
<option value="dni">DNI</option>
<option value="email">EMAIL</option>
</select>
</strong></div></td>
</tr>
<tr>
<td colspan="7"><div align="center">
<input type="submit" name="busqueda" value="REALIZAR BUSQUEDA" />
</div></td>
</tr>
</table>
</form>
<div>';
if (isset($_POST['busqueda']))
{
$bcriterio = $_POST['criterio'];
$bnombre = $_POST['nombre1'];
$bapodo = $_POST['apodo1'];
$bapellido1 = $_POST['apellido11'];
$bapellido2 = $_POST['apellido21'];
$bfecha = $_POST['fecha1'];
$bdni = $_POST['dni1'];
$bemail = $_POST['email1'];
$bequipo = $_POST['equipo1'];
//$query = mysql_query("SELECT * FROM `socios` WHERE `nombre` LIKE '%$bnombre%' AND `apodo` LIKE '%$bapodo%' AND `apellido1` LIKE '%$bapellido1%' AND `apellido2` LIKE '%$apellido2%' AND `fechanacimiento` LIKE '%$bfecha%' AND `dni` LIKE '%$bdni%' AND `email` LIKE '%$bemail%' AND `equipo` LIKE '%$bequipo%' ORDER BY '%$bcriterio%';");
$query = mysql_query('SELECT * FROM `socios` WHERE `nombre` LIKE "%'.$bnombre.'%" AND `apodo` LIKE "%'.$bapodo.'%" AND `apellido1` LIKE "%'.$bapellido1.'%" AND `apellido2` LIKE "%'.$apellido2.'%" AND `fechanacimiento` LIKE "%'.$bfecha.'%" AND `dni` LIKE "%'.$bdni.'%" AND `email` LIKE "%'.$bemail.'%" AND `equipo` LIKE "%'.$bequipo.'%" ORDER BY "%'.$bcriterio.'%";');
echo '<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#66000D">EDIT</td>
<td bgcolor="#66000D">NOMBRE</td>
<td bgcolor="#66000D">APELLIDO1</td>
<td bgcolor="#66000D">APELLIDO2</td>
<td bgcolor="#66000D">APODO</td>
<td bgcolor="#66000D">EQUIPO </td>
<td bgcolor="#66000D">DNI</td>
<td bgcolor="#66000D">FECHA NACIMIENTO</td>
<td bgcolor="#66000D">CORREO</td>
<td bgcolor="#66000D">FECHA ALTA </td>
<td bgcolor="#66000D">FECHA BAJA</td>
</tr>';
while ($row = mysql_fetch_assoc($query))
{
echo '<tr>
<td><form method="post" action="editar_clientes2.php"><input name="servicio" type=submit value='.$row[0].' /></form></td>
<td>'.$row[1].'</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
</table> ';
}
}
echo '</div>
</div>
<div id="contenedor_bajo">PRINCIPAL</div>
</div>
</body>
</html>';
}
else
{
header('Location: index.php');
}
mysql_close();
?>
Cuando entro en mi pagina y le doy a busqueda me sale esto:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/u601714229/public_html/buscador.php on line 121
Esa linea en concreto es:
while ($row = mysql_fetch_assoc($query))
pero esta bien que yo vea y también he comprobado el SQL y esta bien.