• User

    Non sembra funzionare. Non capisco cosa ho sbagliato.

     
    $sql="SELECT * FROM phpbb_topics WHERE forum_id!=2 ORDER BY topic_id DESC LIMIT 5";
    $risultati=mysql_query($sql);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    **$target3=$riga["topic_poster"]; **//questo mi da un numero, sembra funzionare
     
    **$sqlDUE="SELECT * FROM phpbb_users WHERE id='$target3'";**
    **while ($valori = mysql_fetch_array ($sqlDUE)){**
    **$nick = $valori['username']; **//*ho controllato mi pare andasse 'username' e non 'user'*
    **}**
    echo " <tr> ";
    echo " <td style=\"text-align:center; border:1px solid white;\"> <a href=\"<A href="http://www.miodominio.it/forum/viewtopic.php?t=$target1\"><img">http://www.miodominio.it/forum/viewtopic.php?t=$target1\"><img src=\"forum/templates/saphir/images/common/folder_new_hot.gif\" width=\"18\" height=\"20\" border=\"0\"></a> <a href=\"http://www.mio dominio.it/forum/viewtopic.php?t=$target1\" title=\"\"> $target</a> **$target3** **$nick** </td> ";
    echo " </tr>";
     
    }
     
    
    

  • Bannato User Attivo

    Non ti stampa proprio nulla?

    Prova con

    $sqlDUE="SELECT username FROM phpbb_users WHERE id='$target3'";
    while ($valori = mysql_fetch_array ($sqlDUE)){
    **$nick = $valori['username']; **//ho controllato mi pare andasse 'username' e non 'user'
    **}

    **Non ti assicuro nulla...


  • User

    @Napster said:

    Non ti stampa proprio nulla?

    Mi faccio stampare (provvisoriamente) il numero che identifica l'utente, ma per quanto riguarda lo username niente! Non stampa proprio nulla!

    Come posso vedere gli errori?

    PS: il test lo faccio su un secondo dominio, non sul sito vero e proprio!

    PPS: ma... è un'omonimia 😄 o ti sei iscritto al mio forum? Ho come ultimo utente iscritto un certo Napster 😉


  • Bannato User Attivo

    Certo! Ho un sito molto simile al tuo, dal punto di vista del target.
    Entrambi sono destinati agli studenti...

    Cmq...non mi viene in mente altro..Prova a stampare $target3 così vedi se ha preso l'id


  • User

    Bom, ho dovuto anche chiedere ad un mio amico xchè sn imbranato 😄 non m'ero accordo di un id al posto di user_id 🙂

    Vi posto qua sotto la versione perfettamente funzionante!

    
    $database = mysql_connect("host", "UserDatabase", "PasswordDatabase");
    mysql_select_db("NomeDatabase");
     
    $sql="SELECT * FROM phpbb_topics WHERE forum_id!=**2** ORDER BY topic_id DESC LIMIT **5**;";
    $risultati=mysql_query($sql,$database);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    $target3=$riga["topic_poster"];
    $sqlDUE="SELECT * FROM phpbb_users WHERE user_id='".$target3." LIMIT 1;'";
    $risultato=mysql_query($sqlDUE,$database);
    $valori = mysql_fetch_array ($risultato);
    $nick = $valori['username'];
     
    echo " <tr>";
    echo " <td style=\"text-align:center; border:1px solid white;\"> <a href=\"<A href="http://www.TUODOMINIO.it/forum/viewtopic.php?t=$target1\"><img">http://www.TUODOMINIO.it/forum/viewtopic.php?t=$target1\"><img src=\"forum/templates/subSilver/images/common/folder_new_hot.gif\" width=\"18\" height=\"20\" border=\"0\"></a> <a href=\"[http://www.TUODOMINIO.it/forum/viewtopic.php?t=$target1](http://www.TUODOMINIO.it/forum/viewtopic.php?t=$target1\)" title=\"\"> $target</a> (proposto da <a href=\"forum/profile.php?mode=viewprofile&amp;u=".$valori['user_id']."\">".$nick."</a>)</td> ";
    echo " </tr>";
     
    }
    
    

    In rosso vi ho evidenziato le cose da cambiare, rispettivamente: il forum dal quale non volete vengano attinti i topic (tipo io ho escluso le presentazioni, mi sembrava inutile riportare le presentazioni in prima pagina), il numero di titoli che volete vengano riportati in prima pagina (in qst caso vengono riportati solamente gli utimi 5 topic), per finire dovete modificare l'indirizzo del vostro dominio e la locazione dell'immagine da affiancare alle scritte (sempre se la volete!)

    il risultato sarà:

    imageTITOLO DEL TOPIC (proposto da USERNAME AUTORE)

    cliccando su TITOLO DEL TOPIC si va ovviamente nella pagina del topic e cliccando su USERNAME AUTORE si va al profilo dell'autore del topic!

    PS: Il codice funziona senza ulteriori modifiche così com'è se avete phpBB installato nella cartella forum/
    Semmai corregge i percorsi!

    Grazie, Napster! Senza il tuo aiuto ero ancora qui fra 2 anni!


  • User

    Eì possibile partendo da questo script ricavare una mod che ti stampa l'ultimo o gli ultimi topic aperto in home ma visualizzandone il contenuto, un sorta di news automatica?


  • Super User

    @likepassion said:

    Eì possibile partendo da questo script ricavare una mod che ti stampa l'ultimo o gli ultimi topic aperto in home ma visualizzandone il contenuto, un sorta di news automatica?

    Personalmente non credo che la modifica sia possibile (IHMO).

    Nella versione di phpbbplus c'è la possibilità di inserire le "news" nel forum e farle comparire nel portale 😄

    Per fare ciò che desideri, se hai una versione di phpbb 2, credo ci sia una mod da trovare che, al momento, non ho trovato. Magari qualcun'altro sa cosa si può fare 🙂


  • User

    Ciao a tutti...
    Ho provato il codice proposto da ZANARDI ma mi da un errore e non capisco il motivo sinceramente...
    ecco il cod:

    <?php
    $database = mysql_connect("host", "username", "password");
    mysql_select_db("nomedatabase");

    $sql="SELECT * FROM phpbb_topics WHERE forum_id!=2 ORDER BY topic_id DESC LIMIT 5;";
    $risultati=mysql_query($sql,$database);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    $target3=$riga["topic_poster"];
    $sqlDUE="SELECT * FROM phpbb_users WHERE user_id='".$target3." LIMIT 1;'";
    $risultato=mysql_query($sqlDUE,$database);
    $valori = mysql_fetch_array ($risultato);
    $nick = $valori['username'];

    echo " <tr>";
    echo " <td style="text-align:center; border:1px solid white;"> <a href="<A href="http://www.links4you.it/phpBB2/viewtopic.php?t=$target1"><img">http://www.links4you.it/phpBB2/viewtopic.php?t=$target1"><img src="forum/templates/subSilver/images/folder_new_hot.gif" width="18" height="20" border="0"></a> <a href="http://www.links4you.it/phpBB2/viewtopic.php?t=$target1" title=""> $target</a> (proposto da <a href="phpBB2/profile.php?mode=viewprofile&u=".$valori['user_id']."">".$nick."</a>)</td> ";
    echo " </tr>";

    }
    ?>

    Questo è il risultato :

    http://www.links4you.it/phpBB2/viewtopic.php?t=$target1">image $target (proposto da ".$nick.") "; echo " "; } ?>

    HELP PLEASE!!!!!!
    grazie a tutti


  • User

    Ma tu hai scritto così le ultime 3 istruzioni?

    
    echo " <tr>";
    
    echo " <td style=\"text-align:center; border:1px solid white;\"> <a href=\"<A href="http://www.links4you.it/phpBB2/viewtopic.php?t=$target1\"><img">http://www.links4you.it/phpBB2/viewtopic.php?t=$target1\"><img src=\"forum/templates/subSilver/images/folder_new_hot.gif\" width=\"18\" height=\"20\" border=\"0\"></a> <a href=\"http://www.links4you.it/phpBB2/viewtopic.php?t=$target1\" title=\"\"> $target</a> (proposto da <a href=\"phpBB2/profile.php?mode=viewprofile&amp;u=".$valori['user_id']."\">".$nick."</a>)</td> ";
    
    echo " </tr>";
    ```Ho dato un'occhiata veloce al codice riportato da te, mi è sembrato corretto, la prima cosa che ho pensato è stata, probabilmente manca qualche " ma così ad occhio mi pare ci sia tutto.
    
    Probabilmente è solo un errore dovuto alla visualizzazione nel forum (magari ricordati di usare i tag ```
     quando posti del codice ;) ) ma: 
    accertati che le tre istruzioni precedure da echo, siano su 3 righe distinte, nella forma quindi:
    
    [code]echo "      ";
    echo "      ";
    echo "      ";
    

    e non come le hai postate te:

    echo "      ";
    echo " ...
    ...
    ...
    ";
    echo "      "; 
    
    

    Altra cosa che mi viene in mente, è che io uso un foglio di stile, prova a sostituire:

     echo " <td style=\"text-align:center; border:1px solid white;\"> 
    ```con
    
    

    echo "<table style="text-align: center; width: 60%;" border="1" cellpadding="2" cellspacing="2">

    
    e 
    

    </td>

    con
    

    </table>

    Mi scuso se ho detto troppe monate! Facci sapere come va, che proviamo nuovamente!

  • User

    Ho provato ma.... nulla...
    Tengo a precisare che in php non sono una cima.... ma sinceramente non riesco a capire...

    ecco come visualizzo ora :

    "; echo " image $target(proposto da ".$nick.") "; echo " "; } ?>

    ed ecco la parte finale :
    code:

    echo " <tr>";
    echo " <table style="text-align: center; width: 60%;" border="1" cellpadding="2" cellspacing="2">
    <a href="<A href="http://www.links4you.it/phpBB2/viewtopic.php?t=$target1"><img">http://www.links4you.it/phpBB2/viewtopic.php?t=$target1\"<img src="phpBB2/templates/subSilver/images/folder_new_hot.gif" width="18" height="20" border="0"></a><a href="http://www.links4you.it/phpBB2/viewtopic.php?t=$target1" title=""> $target</a>(proposto da <a href="phpBB2/profile.php?mode=viewprofile&u=".$valori['user_id']."">".$nick."</a>)</table> ";
    echo " </tr>";

    alcune cose:

    • il file non deve essere necessariamente .php giusto ? io ce l'ho .html anche perchè la mia home page è in xhtml.
    • echo " " è su tre righe distinte, solo che la seconda essendo lunga la visualizza così.

    grazie per l'aiuto....


  • User

    dimenticavo..... il mio forum è situato nella cartell phpBB2...
    grazie ancora...


  • User

    @fabio.fp said:

    alcune cose:

    • il file non deve essere necessariamente .php giusto ? io ce l'ho .html anche perchè la mia home page è in xhtml.

    Ma certo che SI 😉 Deve essere .php! 🙂

    Ora si spiega tutto, prima cosa rinomina l'estensione della pagina da .html in .php!

    Poi, una volta scelto dove far comparire i 5 nuovi topic, nel codice sorgente della tua pagina scrivi:

    <?php
    

    e a seguire tutto il codice che avevo postato io!
    e concludi con:

    ?> 
    

    Prova, semmai ci sarà forse qualche piccolo ritocco. Facci sapere.


  • User

    forse non mi sono spiegato bene:

    Sto cercando di mettere il tutto in un livello in una pagina html :

    infatti nel codice è già presente l'apertura e la chiusura del php :

    <?php

    codice

    ?>

    :arrabbiato:


  • User Attivo

    Ciao Fabio.fp
    prova così

    
    <?php
    $database = mysql_connect("host", "username", "password");
    mysql_select_db("nomedatabase");
    
    $sql="SELECT * FROM phpbb_topics WHERE forum_id!=2 ORDER BY topic_id DESC LIMIT 5;";
    $risultati=mysql_query($sql,$database);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    $target3=$riga["topic_poster"];
    $sqlDUE="SELECT * FROM phpbb_users WHERE user_id='".$target3." LIMIT 1;'";
    $risultato=mysql_query($sqlDUE,$database);
    $valori = mysql_fetch_array ($risultato);
    $nick = $valori['username'];
    
    echo ' <tr>';
    echo '<td style="text-align:center; border:1px solid white;"> <a href="http://www.links4you.it/phpBB2/viewtopic.php?t='.$target1.'"><img src="forum/templates/subSilver/images/folder_new_hot.gif" width="18" height="20" border="0"></a><a href="http://www.links4you.it/phpBB2/viewtopic.php?t='.$target1.'" title="">'.$target.'</a> (proposto da <a href="phpBB2/profile.php?mode=viewprofile&amp;u='.$valori['user_id'].'">'.$nick.'</a>)</td> ';
    echo ' </tr>';
    
    }
    ?>
    

  • User

    Grazie Jantima..... gentilissima.....
    Provo e ti faccio sapere....
    😉


  • User

    questo è ciò che vedo ....:

    code:

    '; echo ' image'.$target.' (proposto da '.$nick.') '; echo ' '; } ?>

    giuro.... non capisco il motivo....
    :arrabbiato:


  • User Attivo

    Ciao, se sei ancora in ballo col problema, potresti ri-postare tutto il codice che usi?


  • User Attivo

    Ho provato anch'io ad adoperare il codice che hai postato, Jantima.
    Il forum sta in root/phpBB3/ mentre lo script.php sta in root.
    Ho adattato il codice così, ma quando eseguo la pagina nel browser non appare nulla.
    [php]<?php
    $database = mysql_connect("localhost", "username", "pass");
    mysql_select_db("databasename");

    $sql="SELECT * FROM phpbb3_topics WHERE forum_id!=2 ORDER BY topic_id DESC LIMIT 5;";
    $risultati=mysql_query($sql,$database);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    $target3=$riga["topic_poster"];
    $sqlDUE="SELECT * FROM phpbb3_users WHERE user_id='".$target3." LIMIT 1;'";
    $risultato=mysql_query($sqlDUE,$database);
    $valori = mysql_fetch_array ($risultato);
    $nick = $valori['username'];

    echo ' <tr>';
    echo '<td style="text-align:center; border:1px solid white;"> <a href="http://sito.it/phpBB3/viewtopic.php?t='.$target1.'"><img src="http://sito.it/phpBB3/styles/prosilver/imageset/sticky_unread.gif" width="18" height="20" border="0"></a><a href="http://sito.it/phpBB3/viewtopic.php?t='.$target1.'" title="">'.$target.'</a> (proposto da <a href="http://sito.it/phpBB3/profile.php?mode=viewprofile&u='.$valori['user_id'].'">'.$nick.'</a>)</td> ';
    echo ' </tr>';

    }
    ?>[/php]Dove username, pass e databasename sono nome utente del database, password e nome del database. E' su Altervista.


  • User Attivo

    Ciao a tutti, ho provato il codice di zanardi e ho pulito alcune cosette, questa versione è funzionante (potete vedere [url=http://www.antiworld.biz/antiworld/news1.php]qui)
    Questo è il codice:
    [php]
    mysql_connect("localhost", "bd_user","db_pass") or die("The page is currently going through some major updates and will be back soon.");
    mysql_select_db("db_name") or die("Unable to connect to database");

    $sql="SELECT * FROM phpbb_topics WHERE forum_id!=2 ORDER BY topic_id DESC LIMIT 5";
    $risultati=mysql_query($sql);
    echo '<table>';
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["topic_title"];
    $target1=$riga["topic_id"];
    $target3=$riga["topic_poster"];
    $sqlDUE="SELECT * FROM phpbb_users WHERE user_id='".$target3." LIMIT 1;'";
    $risultato=mysql_query($sqlDUE);
    $valori = mysql_fetch_array ($risultato);
    $nick = $valori['username'];

    echo '<tr>';
    echo '<td><a href="http://www.TUODOMINIO.it/forum/viewtopic.php?t='.$target1.'"><img src="http://www.TUODOMINIO.it/forum/viewtopic.php?t='.$target1.'"><img src="forum/templates/subSilver/images/common/folder_new_hot.gif" width="18" height="20" border="0"></a><a href="http://www.TUODOMINIO.it/forum/viewtopic.php?t='.$target1.'" title="">'.$target.'</a> (proposto da <a href="forum/profile.php?mode=viewprofile&u='.$valori['user_id'].'">'.$nick.'</a>)</td>';
    echo '</tr>';
    }
    echo '</table>';
    [/php]

    Per chi volesse anche un estratto del post insieme alla lista dei posts, recenti ho messo insieme un codice prelevato dal RSS feed.
    [url=http://www.antiworld.biz/antiworld/news-e-feed.php]Questa la pagina esempio
    e questo il codice:
    [php]
    <?
    mysql_connect("localhost", "bd_user","db_pass") or die("The page is currently going through some major updates and will be back soon.");
    mysql_select_db("db_name") or die("Unable to connect to database");

    $sql = "SELECT topic_id, MAX(post_time) post_time
    FROM phpbb_posts
    WHERE forum_id IN (1, 3, 4, 5, 6, 9, 13, 14, 11, 16, 18, 19, 20, 21)
    GROUP BY topic_id
    ORDER BY post_time DESC
    LIMIT 0,15";

    $results=mysql_query($sql);
    ?>
    <a href="http://www.antiworld.biz"><h2>Recent Topics From the CTF Forums</h2></a>

    <?
    while($row=mysql_fetch_array($results))
    {
    $sql2 = "
    SELECT t.topic_title, f.forum_name,pt.post_text, t.topic_replies, u.username, p.post_time, p.post_id
    FROM phpbb_posts p,
    phpbb_users u,
    phpbb_forums f,
    phpbb_topics t,
    phpbb_posts_text pt
    WHERE p.post_time = ".$row['post_time']."
    AND p.topic_id = ".$row['topic_id']."
    AND p.poster_id = u.user_id
    AND p.forum_id = f.forum_id
    AND p.topic_id = t.topic_id
    AND pt.post_id = p.post_id";
    $results2=mysql_query($sql2);
    $row2=mysql_fetch_array($results2);
    //t.topic_type
    $username=$row2["username"];
    $topic_title=$row2["topic_title"];
    $post_id=$row2["post_id"];
    $forum_name=$row2["forum_name"];
    $post_time=$row2["post_time"];
    $topic_replies=$row2["topic_replies"];
    $text = $row2["post_text"];
    ?>

        <a href="http://www.antiworld.biz/antiworld/viewtopic.php?p=<?=$post_id?>">  <h4><?=$topic_title?></h4></a>
    
        <?=substr($text,0,200)?>  
        <br />
    

    <strong>Autore:</strong>
    <?=$username?>
    <strong>Pubblicato il:</strong>
    <?=date("D, d M Y G:i O",$post_time)?><br />

    <?
    }
    ?>

    [/php]

    Vi ricordo inoltre topics anywhere, è uno strumento utile per creare un javascript o dei RSS che mostrno gli ultimi posts e metterli in qualsiasi pagina in qualsiasi sito. (il mio è [url=http://www.antiworld.biz/antiworld/topics_anywhere.php]visibile qui). Il risultato ottenuto con topics anywhere sta nella home del sito sotto a "Recent Topics From the CTF Forums"

    Ho anche altri scriptini usati in passato per fare la lista degli ultimi topics.
    Questo è uno molto molto semplice che lista solo i titoli ([url=http://www.antiworld.biz/antiworld/news2.php]visibile qui)
    [php]
    <?
    include('db_connect.php');
    // if you want to exclude any forums just add the id to the NOT IN (.......)
    $sql = "SELECT *
    FROM phpbb_posts_text pt LEFT JOIN phpbb_posts p ON pt.post_id = p.post_id
    WHERE pt.post_subject!=''
    AND p.forum_id NOT IN (2,7,8,15)
    ORDER BY pt.post_id DESC LIMIT 0,50";

    $results=mysql_query($sql);
    while($row=mysql_fetch_array($results))
    {
    $target=$row["post_subject"];
    $target1=$row["post_id"];
    echo "<a href="http://www.antiworld.biz/antiworld/viewtopic.php?p=$target1" title="">$target</a><br>";
    }
    ?>
    [/php]
    Questo è un altro, visibile [url=http://www.antiworld.biz/antiworld/news5.php]qui
    [php]
    <?
    include('db_connect.php');

    $sql = "SELECT topic_id, MAX(post_time) post_time
    FROM phpbb_posts
    WHERE forum_id IN (1, 3, 4, 5, 6, 9, 13, 14, 11, 16, 18, 19, 20, 21)
    GROUP BY topic_id
    ORDER BY post_time DESC
    LIMIT 0,15";

    $results=mysql_query($sql);

    while($row=mysql_fetch_array($results))
    {
    $sql2 = "
    SELECT t.topic_title, f.forum_name, t.topic_replies, u.username, p.post_time, p.post_id
    FROM phpbb_posts p,
    phpbb_users u,
    phpbb_forums f,
    phpbb_topics t
    WHERE p.post_time = ".$row['post_time']."
    AND p.topic_id = ".$row['topic_id']."
    AND p.poster_id = u.user_id
    AND p.forum_id = f.forum_id
    AND p.topic_id = t.topic_id";
    $results2=mysql_query($sql2);
    $row2=mysql_fetch_array($results2);
    //t.topic_type
    $username=$row2["username"];
    $topic_title=$row2["topic_title"];
    $post_id=$row2["post_id"];
    $forum_name=$row2["forum_name"];
    $post_time=$row2["post_time"];
    $topic_replies=$row2["topic_replies"];
    ?>
    <a href="http://www.antiworld.biz/antiworld/viewtopic.php?p=<?=$post_id?>" title="<?=$topic_title?>"><?=$topic_title?></a> in <?=$forum_name?> (<?=$topic_replies?> Replies) - <?=$username?>, <?=$post_time?><br>

    <?
    }
    ?>
    [/php]


  • User Attivo

    Bel lavoro! Era proprio quello che cercavo!

    Grande Napster!