Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/04/2005, 11:59
pablud
 
Fecha de Ingreso: enero-2005
Ubicación: Zaragoza
Mensajes: 3
Antigüedad: 19 años, 3 meses
Puntos: 0
Efectivamente era un error de transcripción.

No es un error de la base de datos ya que si meto el código de la función de la consulta SQL dentro de la función que pinta la tabla, todo funciona correctamente. A mi entender el problema viene por la variable $result que no recibe correctamente el recordset de la consulta.

A continuación pongo las dos funciones:

Código PHP:
function dame_ultimos_post_foro($forumid,$num_post){
    global 
$db;
    
$result $db->sql_query("SELECT  vb3_post.postid, vb3_post.threadid, vb3_post.username, vb3_post.userid, vb3_thread.title, vb3_post.dateline, vb3_forum.title FROM vb3_post, vb3_thread, vb3_forum WHERE vb3_thread.threadid=vb3_post.threadid and vb3_thread.forumid=$forumid and vb3_thread.forumid=vb3_forum.forumid ORDER BY vb3_post.dateline DESC LIMIT $num_post");
    return 
$result;

Función que muestra en una tabla el resultado de la consulta:

Código PHP:
function muestra_ultimos_post_foro_tabla($forumid$num_post){
    global 
$db;
        
$result=dame_ultimos_post_foro($forumid_id,$num_post);
        
$nombre_foro=dame_nombre_foro($forumid);       
        echo 
"<table width=\"700\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
    echo 
" <tr>\n";
    echo 
"    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
    echo 
"        <tr>\n";
    echo 
"          <td width=\"21\" height=\"31\" background=\"images/top_left.gif\">&nbsp;</td>\n";
    echo 
"          <td width=\"200\" height=\"31\" valign=\"bottom\" background=\"images/top_bg.gif\"><div align=\"center\"><strong>En estos momentos en el Foro de $nombre_foro</strong> </div></td>\n";
    echo 
"          <td width=\"18\" height=\"31\" background=\"images/top_end.gif\">&nbsp;</td>\n";
    echo 
"          <td width=\"447\" height=\"31\" background=\"images/top_center.gif\">&nbsp;</td>\n";
    echo 
"          <td width=\"14\" height=\"31\" background=\"images/top_right.gif\">&nbsp;</td>\n";
    echo 
"        </tr>\n";
    echo 
"      </table></td>\n";
    echo 
"  </tr>\n";
    echo 
"  <tr>\n";
    echo 
"    <td valign=\"top\"><table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#D7DEE3\">\n";
    echo 
"        <tr bgcolor=\"#D4CFC0\">\n"
    echo 
"          <td width=\"234\"><div align=\"left\">Usuario</div></td>\n";
    echo 
"          <td width=\"303\"><div align=\"left\">T&iacute;tulo</div></td>\n";
    echo 
"          <td width=\"93\"><div align=\"left\">Fecha</div></td>\n";
    echo 
"          <td width=\"70\"><div align=\"left\">Ir a foro</div></td>\n";
    echo 
"        </tr>\n";
    while (
$row=$db->sql_fetchrow($result)){
    
$post_id=$row['postid'];
    
$tema_id=$row['threadid'];
    
$usuario=$row['username'];
    
$usuario_id=$row['userid'];
    
$titulo_thread=$row['title'];
    
$fecha=date("d/m/Y H:i",$row['dateline']);
    if (
$li==10)
        {
        break;
    }
    
$li+=1;
    echo 
"        <tr bgcolor=\"#DFE6EF\">\n";
    echo 
"          <td width=\"234\">$usuario</td>\n";
    echo 
"          <td width=\"303\"><a href=\"http://lawebresponde.com/foro/showthread.php?t=$tema_id\">$titulo_thread</a></td>\n";
    echo 
"          <td width=\"93\">$fecha</td>\n";
    echo 
"          <td width=\"70\"><a href=\"http://lawebresponde.com/foro/showthread.php?t=$tema_id#post$post_id\">Ver</a></td>\n";
    }
    echo 
"        </tr>\n";
    echo 
"      </table></td>\n";
    echo 
"  </tr>\n";
    echo 
"  <tr>\n";
    echo 
"    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
    echo 
"        <tr>\n";
    echo 
"          <td width=\"11\" height=\"18\" background=\"images/blc.gif\">&nbsp;</td>\n";
    echo 
"          <td width=\"677\" height=\"18\" background=\"images/fondo.gif\">&nbsp;</td>\n";
    echo 
"          <td width=\"12\" height=\"18\" background=\"images/brc.gif\">&nbsp;</td>\n";
    echo 
"        </tr>\n";
    echo 
"      </table></td>";
    echo 
"  </tr>\n";
    echo 
"</table>";
    echo 
"<p>&nbsp;</p>";
      

Muchas gracias.
Un saludo.