Código PHP:
<?
// Script producido por Angarzafir para manganimart...
// Cantidad de post a mostrar y prefijo de las tablas
$ultimos = 5; //5 temas
$prefijo = "phpbb_";
$largo = 200; //caracteres del mensaje
$categoria = 6; //categoria de los forums
// Consultas a la base
// mostrar todos los datos de los ultimos 5 topicos publicados de esta categoria
$con= mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname,$conexion);
$result_mensaje=mysql_query("select * from FROM phpbb_forums, phpbb_posts, phpbb_topics ORDER BY `phpbb_posts`.`topic_id` DESC where parent_id like $categoria order by topic_id desc limit $ultimos",$con);
//Hacer mientras hayan registros en la consulta
while($mostrar_m = mysql_fetch_array($result_mensaje)) {
//guardar topico y foro dentro de variables
//para obtener por categorias solo busco el nombre del campo y lo guardo
$topic= $mostrar_m["topic_id"];
$topic_name=$mostrar_m["topic_title"];
$forum=$mostrar_m["forum_name"];
$mensaje = substr($mostrar_m["post _text"],0,200);
$vistas= $mostrar_m["topic_views"];
$usuario= $mostrar_m["topic_first_poster_name"];
//imprimir resultados
?>
<font face="verdana" size="1">» <a href="http://www.tusitio.com/foro/viewtopic.php?t=<?=$topic;?>" target="_blank"><? echo $mostrar_m["topic_name"]; ?></a><br> <? echo $mostrar_m["mensaje"]; ?><i><b><?=$forum_name;?></b></i></font><br>
<?
//seguir el bucle
}
// Cerramos conexión
mysql_free_result($result_mensaje);
mysql_close($con);
?>
Cita:
No entiendo porque me sale el acceso denegado cuando un script en la misma pagin y que trabaja a la perfección. Aqui se los dejo...Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO)
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
Warning: mysql_free_result(): supplied argument is not a valid MySQL result
Warning: mysql_close(): supplied argument is not a valid MySQL-Link
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
Warning: mysql_free_result(): supplied argument is not a valid MySQL result
Warning: mysql_close(): supplied argument is not a valid MySQL-Link
Código PHP:
<?
// Últimos mensajes publicados en foros phpBB2.
// Creado por XeRGio
// <a href="visitar.php?http://www.xergio.net" target="_blank">www.xergio.net</a>
//
// Edita lo que viene a continuación. Cambia solo lo que hay entre comillas "":
$directorio = "foro"; //Carpeta donde esta situadoel foro.
$mostrar = "10"; //Número de mensajes a mostrar.
$caracteres = "18"; //Caracteres que se mostrarán de cada línea.
// Lo que viene ahora no lo toques para nada!!! a no ser que sepas de qué va el tema...
include("$directorio/config.php");
echo "
<script type=text/javascript>
function sobre(texto) { subnav.innerHTML = texto; }
function fuera(texto) { subnav.innerHTML = \"<a href=$directorio/index.php> Entrar en el índice de Foros</a>\" }
</script>
";
$conexion = mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname,$conexion);
$consulta = "select * from ".$table_prefix."posts order by post_time desc";
$resultado = mysql_query($consulta);
$i = 0;
while ($rows = mysql_fetch_array($resultado)) {
if ($i <= $mostrar) {
$consulta1 = "select * from ".$table_prefix."forums where forum_id='$rows[forum_id]'";
$resultado1 = mysql_query($consulta1);
$datosf = mysql_fetch_array($resultado1);
$consulta2 = "select * from ".$table_prefix."users where user_id='$rows[poster_id]'";
$resultado2 = mysql_query($consulta2);
$datosu = mysql_fetch_array($resultado2);
$consulta3 = "select * from ".$table_prefix."topics where topic_id='$rows[topic_id]'";
$resultado3 = mysql_query($consulta3);
$datost = mysql_fetch_array($resultado3);
if (strlen($datost[topic_title]) > $caracteres) {
$datost[topic_title] = substr($datost[topic_title],0,20)."...";
}
echo "›<b>›</b> <a href=\"$directorio/viewtopic.php?t=$rows[topic_id]\" onmouseover='sobre(\" › en <b>$datosf[forum_name]</b> por <i>$datosu[username]</i></font>\")' onmouseout='fuera()'>$datost[topic_title]</a><br>";
$i++;
}
}
echo "<br><table width=100% border=0 cellpadding=0 cellspacing=0><tr><td id=subnav name=subnav><a href=$directorio/index.php> Entrar en el índice de Foros</a></td></tr></table>";
mysql_free_result($resultado);
mysql_close($conexion);
?>