Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/10/2009, 13:03
Avatar de thaproducer
thaproducer
 
Fecha de Ingreso: junio-2008
Ubicación: Puerto Vallarta, Jalisco
Mensajes: 107
Antigüedad: 15 años, 10 meses
Puntos: 0
Error de sintaxis

Saludos compañeros, ojalá me puedan ayudar con este error de sintaxis:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY fecha DESC 1' at line 1

Resulta que estoy creando un pequeño foro que tiene 3 columnas, "Temas", "total de comentarios" y "ultimo comentario". Dentro de tema y total de comentarios ya logré que aparezcan los datos correspondientes, pero el problema es dentro de "ultimo comentario" donde abajito también aparecerá la fecha en que comentaron.

Este es código de la tabla:

Código:
<table border="0" cellpadding="8" cellspacing="0" class="categorias">
  <tr>
    <th>Temas</th>
    <th>Total de comentarios </th>
    <th>Ultimo comentario </th>
  </tr>
  <?php do { ?>
  <?php
  mysql_select_db($database_foro_cuc, $foro_cuc);
  $publicacion_sql = "SELECT id_mensaje FROM mensajes WHERE categoria = "  .
  $row_foros['id_categoria'];
  
  $ultimosql = "SELECT autor, fecha FROM mensajes WHERE categoria = " .
  $row_foros['id_categoria'] . "ORDER BY fecha DESC LIMIT 1";
  
  $uPost = mysql_query($ultimosql) or die(mysql_error());
    
  $pTotales = mysql_query($publicacion_sql) or die (mysql_error());
  
  ?>
    <tr>
      <td><a href="categorias.php?cat=<?php echo $row_foros['id_categoria']; 
	  ?>"><?php echo $row_foros['nombre']; ?></a>
      <p><?php echo $row_foros['descripcion']; ?></p></td>
      <td align="center"><?php echo mysql_num_rows($pTotales); ?></td>
      <td align="center"><?php 
	  $up = mysql_fetch_assoc ($uPost); 
	  echo $up['fecha'];
	  echo '<br />';
	  echo $up['autor'];
	  ?></td>
    </tr>
    <?php } while ($row_foros = mysql_fetch_assoc($foros)); ?>
</table>
SOLUCIONADO

Última edición por thaproducer; 31/10/2009 a las 14:15