Foros del Web » Programando para Internet » PHP »

ayuda php

Estas en el tema de ayuda php en el foro de PHP en Foros del Web. Hola ,haber si alguien sabe decirme q cambiar para q no me de el siguiente Error. You have an error in your SQL syntax near ...
  #1 (permalink)  
Antiguo 10/06/2003, 17:28
 
Fecha de Ingreso: junio-2002
Mensajes: 70
Antigüedad: 21 años, 9 meses
Puntos: 0
ayuda php

Hola ,haber si alguien sabe decirme q cambiar para q no me de el siguiente Error.
You have an error in your SQL syntax near 'and ) and (u.email=i.email) limit 5, 5' at line 1


Hola tengo el siguiente error despues de hacer una consulta y darle a "weiter" siguientes resultados para q muestre en otra pagina mas resultados de dciha busqueda.

You have an error in your SQL syntax near 'and ) and (u.email=i.email) limit 5, 5' at line 1

//*este es el codigo q creo q falla */

<?
session_register('$logueado');

if (!$logueado)
{
header("location: login.php");
}

include("incs/funcs.inc.php");
connect();

$query="select * from usuarios as u, images as i where u.id_sexo='$sexo' and u.id_lenguaje='$lenguaje' and u.fuma='$fuma' and u.id_pais='$pais' and u.id_relacion_buscada='$relacion_buscada' and (u.edad between $edad1 and $edad2) and (u.email=i.email) limit $offset, $resultados";
//$query="select * from usuarios, images where (usuarios.email=images.email) limit $offset, $resultados"; //todos
$rusers=mysql_query($query) or die (mysql_error());

//me das las filas de todos los resultados que cumplen la condicion, para que desaparezca la flecha para ir para adelante cuando no hay mas resultados que mostrar
$qcounter="select * from usuarios as u, images as i where u.id_sexo='$sexo' and u.id_lenguaje='$lenguaje' and u.fuma='$fuma' and u.id_pais='$pais' and u.id_relacion_buscada='$relacion_buscada' and (u.edad between $edad1 and $edad2) and (u.email=i.email)";
//$qcounter="select * from usuarios, images where (usuarios.email=images.email) limit $offset, $resultados";
$rcounter=mysql_query($qcounter) or die (mysql_error());
$cantidad=mysql_num_rows($rcounter);

?>

<html>
<head>
<title>:: FlirtMonopol ::</title>
<link rel="stylesheet" type="text/css" href="/styles.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#990000" text="#000000" background="img/top1.gif">

<?include ("incs/top.inc.htm")?>

<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" bordercolor="#FF0000" class="TextNormal">
<tr>
<td> </td>
<td>


<?
if ($cantidad==0)
{
echo '<table width="27%" border="0" align="center" cellpadding="0" cellspacing="0" class=TextNormal2>';
echo "Zu Ihrer Suchanfrage wurde leider kein Ergebnis gefunden.";
echo '</table>';
}
else
{

?>


<? while ($row=mysql_fetch_array($rusers))
{
?>

<table width="27%" border="0" align="center" cellpadding="0" cellspacing="0" class=TextNormal>

<tr>
<td width="12"><img src="/img/arr_izq.gif" width="12" height="12"></td>
<td background="/img/arr.gif"><img src="/img/arr.gif" width="3" height="12"></td>
<td width="12"><img src="/img/arr_der.gif" width="12" height="12"></td>

<? if ($chkfoto)
{
?>
<td width="12"><img src="/img/arr_izq.gif" width="12" height="12"></td>
<td background="/img/arr.gif"><img src="/img/arr.gif" width="3" height="12"></td>
<td width="12"><img src="/img/arr_der.gif" width="12" height="12"></td>

<?
}
?>
</tr>


<tr>
<td width="12" background="/img/izq.gif"><img src="/img/izq.gif" width="12" height="3"></td>

<td>
<?
echo '<div align="center">';
echo "Descripcion: ".$row["descrip"];
$encriptado = bin2hex($row["email"]);
?>
<form action="show_info.php" method="POST">
<input type="hidden" name="mailcrypted" value="<?echo $encriptado;?>">

<input type="submit" name="Submit" value="Mehr info">
</form>
</div>
</td>

<td width="12" background="/img/der.gif"><img src="/img/der.gif" width="12" height="8"></td>

<? if ($chkfoto)
{
?>
<td width="12" background="/img/izq.gif"><img src="/img/izq.gif" width="12" height="3"></td>
<td>

<img src="/users_pics/<?php echo $row["pic_name"];?>">

</td>
<td width="12" background="/img/der.gif"><img src="/img/der.gif" width="12" height="8"></td>

<?
}
?>
</tr>


<tr>
<td width="12"><img src="/img/aba_izq.gif" width="12" height="12"></td>
<td background="/img/aba.gif"><img src="/img/aba.gif" width="2" height="12"></td>
<td width="12"><img src="/img/aba_der.gif" width="12" height="12"></td>

<? if ($chkfoto)
{
?>
<td width="12"><img src="/img/aba_izq.gif" width="12" height="12"></td>
<td background="/img/aba.gif"><img src="/img/aba.gif" width="2" height="12"></td>
<td width="12"><img src="/img/aba_der.gif" width="12" height="12"></td>
<?
}
?>
</tr>

</table>

<? echo "<br>";
}
?>


<table align="center" bordclass="TextNormal">
<tr>
<td>
<? if (($offset-$resultados)>=0)
{ ?>
<a href="do_search.php?offset=<?
if ($chkfoto)
echo $offset-$resultados.'&chkfoto=1&resultados='.$resultados;
else
echo $offset-$resultados.'&resultados='.$resultados;
?>" class="TextNormal2">Zurück</a>
<? } ?>
</td>

<td class="TextNormal2">|</td>

<td>
<? if (($offset+$resultados)<=$cantidad)
{
?>
<a href="do_search.php?offset=<?
if ($chkfoto)
echo $offset+$resultados.'&chkfoto=1&resultados='.$resu ltados;
else
echo $offset+$resultados.'&resultados='.$resultados;
?>" class="TextNormal2">Weiter</a>
<? }
?>

</td>
</tr>

</table>
</td>
<td> </td>
</tr>

<tr>
<td width="19%"> </td>
<td width="60%">

<?
}?>


<?include ("incs/footer.inc.php")?>
</td>
<td width="21%"><div align="center"></div></td>
</tr>
</table>


</body>
</html>
__________________
Rob
Queridas Islas cies te estan llenando de fuel , ¡¡¡putos políticos de mierda que me las vais a joder(os quería ver nandando en fuel a todos CABRONES¡¡¡

Última edición por Rober1978; 10/06/2003 a las 18:17
  #2 (permalink)  
Antiguo 10/06/2003, 17:45
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Si usas el boton "PHP" al poner tu código veras que se colorea y queda más claro.

Si el error es de "SQL" como ahí dice .. con que pongas el SQL que empleas sobra:

Código PHP:
$query="select * from usuarios as u, images as i where u.id_sexo='$sexo' and u.id_lenguaje='$lenguaje' and u.fuma='$fuma' and u.id_pais='$pais' and u.id_relacion_buscada='$relacion_buscada' and (u.edad between $edad1 and $edad2) and (u.email=i.email) limit $offset, $resultados"
Yo pondría comillas a las llamadas a variables PHP, Por lo demas .. between .. es una función de Msyql .. sus parámetros no van entre parentesis .. :

Código PHP:
$query="select * from usuarios as u, images as i where u.id_sexo='$sexo' and u.id_lenguaje='$lenguaje' and u.fuma='$fuma' and u.id_pais='$pais' and u.id_relacion_buscada='$relacion_buscada' and u.edad between '$edad1' and '$edad2' and u.email=i.email limit $offset, $resultados"
Cualquier duda .. www.mysql.com/doc (y busca la sintax correcta de lo que uses ...)

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.

Última edición por Cluster; 10/06/2003 a las 17:47
  #3 (permalink)  
Antiguo 11/06/2003, 06:06
 
Fecha de Ingreso: junio-2002
Mensajes: 70
Antigüedad: 21 años, 9 meses
Puntos: 0
Problemas busuqedas

Hola ,gracias por tu explicación he echo eso q me psoteaste , y ya no me da ese error ,pero no hace las busquedas bien , pues me salen la primera pagina de la busqueda y al darle a la siguiente pagina para q me muestre el siguiente de resultados de dicha busqueda , me sale el boton anteriores ,le doy y me sale busuqedas diferentres ,no las de la pagina anterior.

Saludos
gracias de antemano
__________________
Rob
Queridas Islas cies te estan llenando de fuel , ¡¡¡putos políticos de mierda que me las vais a joder(os quería ver nandando en fuel a todos CABRONES¡¡¡
  #4 (permalink)  
Antiguo 11/06/2003, 14:42
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Bueno .. pues ahora es problema de tu lógica de "paginado" .. Ahí ya no me fijé .. Mucho código y sin datos para probar (estructura de tu tabla y datos ejemplo) es un pco complicado ver el error a simple vista .. De todas formas .. insiste en tu problema .. resume el código si puedes localiza el código que pueda fallar .. etc ..

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
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 20:41.