Problema Con "Ultimos Mensajes En Web"
Publicado: 15 Sep 2006, 16:01
No sabía si ponerle en este foro o en el de soporte. Si está mal, pido disculpas.
El caso es que he intentado poner el sigiente código (sacado de otro mensaje de este foro) para mostrar los últimos mensajes de mi foro en la página web, y así tenerla "dinámica".
La web del foro es http://proaninet.phpnet.us/foro; la de la página es http://proaninet.phpnet.us/
Al ejecutarlo, da error de conexion 2, o sea que lo que falle es al realizar esta operación:
¿Algún alma caritativa me ayuda? Porque llevo toda la mañana y la tarde partiendome la cabeza, y no se me ocurre nada que deba modificar......
Muchísimas gracias por adelantado.
Saludos. Álvaro.
El caso es que he intentado poner el sigiente código (sacado de otro mensaje de este foro) para mostrar los últimos mensajes de mi foro en la página web, y así tenerla "dinámica".
Código: Seleccionar todo
<?php
//
// Configuracion Basica
// Cuantos Topics Quieres Mostrar?
$topicnumber = 10;
// Scrolling up = arriba down = abajo
$scroll = "up";
// Path del foro
$urlPath = "http://proaninet.phpnet.us/foro";
// configuracion de acceso a la bbdd (donde tienes puesto el config)
include 'foro/config.php';
// Conectando a la BBDD y selecionando Tablas
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("No Puedo Conectar");
mysql_select_db("$dbname") or die("error de Conexion 1");
// Consulta
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id,
u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
AND f.auth_view = " . AUTH_ALL . "
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("error de Conexion 2");
// Salida HTML
// Ves con cuidado cuando edites esto!
print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"170\" scrolldelay=\"100\"
scrollamount=\"2\" onMouseOver=\"document.all.recent_topics.stop()\" onMouseOut=\"document.all.recent_topics.start()\">
<table cellpadding='3' cellSpacing='2' width='350'>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr valign='top'><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#FFCC00\"><b><a
href=\"$urlPath/viewtopic.php?topic=$row[topic_id]\">" .
$row["topic_title"] .
"</a></td></font></b><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> by: <a
href=\"$urlPath/profile.php?mode=viewprofile&u=$row[user_id]\">" .
$row["username"] .
"</td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\">" .
date('F j, Y, g:i a', $row["post_time"]) .
"</td></tr></font>";
}
print "</table></marquee>";
// Liberamos Salida
mysql_free_result($result);
// Cerramos Conexion no necesario si no fastidiara toda la Web
//mysql_close($link);
?>
Al ejecutarlo, da error de conexion 2, o sea que lo que falle es al realizar esta operación:
Código: Seleccionar todo
// Consulta
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id,
u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
AND f.auth_view = " . AUTH_ALL . "
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("error de Conexion 2");
Muchísimas gracias por adelantado.
Saludos. Álvaro.