MyBB Community Forums

Full Version: Latest Thread Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Im using the code below to display the latest threads on a webpage from my forum. Im using the same code on another website and ive just changed the url in the code to use it with another forum, but it wont display the latest threads. Can anyone spot what im doing wrong ?

<html>
<head>
</head>
<body>
<body bgcolor="Silver"> 
<br>
<?php
chdir("http://www.windowsfreebies.com/"); // path to MyBB
define("IN_MYBB", 1);
require("global.php");
?>

<?php

    $query = mysql_query("
            SELECT t.*, u.username
            FROM mybb_threads t
            LEFT JOIN mybb_users u ON (u.uid=t.uid)
            WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, 10" // Change the last digit to how many recent post you want to be shown
        );

    $list = '';
    while($fetch = mysql_fetch_array($query))
    {
        $list .= "<strong><a href=http://www.windowsfreebies.com/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
        $poster = "<a href=http://www.windowsfreebies.com/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
        $list .= "Created by: {$poster}<br />";
        $list .= "<i>" .$fetch['replies']. " Replies</i>";
        $list .= " (<i>Last post by: " .$fetch['lastposter']. "</i>)<br /><hr width=\"50\"><br />";
    
    }
    //output
    echo $list;
    
?>
</body>
</html>

Its just displaying a blank page : http://www.windowsfreebies.com/latestthreadspopup.php
Is this in your forum folder? Or is you forum in a subdomain?
Yes its in my forum root

I have this working on another forum (version 1.4.11) the only difference that ive made to the code is the URL's and its mybb version 1.4.13.

The file structure is identical on both forums. So why the hell wont it work ?

Ive now tried this on another domain i have "mybbcenter.com" and it works perfectly.

<html>
<head>
<center>
</head>
<body>
<body bgcolor="#EFEFEF">  
<br>
<?php
chdir("http://mybbcenter.com/"); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
?>

<?php

    $query = mysql_query("
            SELECT t.*, u.username
            FROM mybb_threads t
            LEFT JOIN mybb_users u ON (u.uid=t.uid)
            WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, 100" // Change the last digit to how many recent post you want to be shown
        );

    $list = '';
    while($fetch = mysql_fetch_array($query))
    {
        $list .=  "Thread: <strong><i>".htmlspecialchars_uni($fetch['subject'])."</strong></i><br />";
        $poster = "<a href=http://www.mybbcenter.com/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
        $list .= "<i>" .$fetch['replies']. "Replies </i><br />";
        $list .= " (<i>Last post by: " .$fetch['lastposter']."</i>)<br /><hr width=\"50\">";
    }
    //output
    echo $list;
    
?>
</body>
</html>
Try putting the URL simply to /
Yea ive tried that, doesnt work. I cant believe this, it works on every domain that i own apart from this one, unbelievable.

Heres the other domain that its working on : http://mybbcenter.com/latestthreadspopup.php
You can put all of the php code in one set of "<?php ?>" tags Smile
Yea did that there now , still no luck.
what the hell is going on here , its works with any other domain, why isnt it displaying the php ?

http://www.windowsfreebies.com/latestthreadspopup.php
This is the source:

<html> 
<head> 
<center> 
</head> 
<body> 
<!--<body background="/images/black/bg.png">--> 
<body bgcolor="#EFEFEF"> 
<br> 
</body> 
</html>

Not sure what's going on with that...
Yea i know , its crazy , it works on all of my other forums , but when i change the url to "www.windowsfreebies.com" it work work , just shows a blank page. weird as hell

Edit: dont mind that html lol

This is the complete code that im using:

<html>
<body>
<body bgcolor="Silver"> 
<br>
<?php
chdir("http://www.windowsfreebies.com/"); // path to MyBB
define("IN_MYBB", 1);
require("global.php");
?>

<?php

    $query = mysql_query("
            SELECT t.*, u.username
            FROM mybb_threads t
            LEFT JOIN mybb_users u ON (u.uid=t.uid)
            WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, 10" // Change the last digit to how many recent post you want to be shown
        );

    $list = '';
    while($fetch = mysql_fetch_array($query))
    {
        $list .= "<strong><a href=http://www.windowsfreebies.com/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
        $poster = "<a href=http://www.windowsfreebies.com/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
        $list .= "Created by: {$poster}<br />";
        $list .= "<i>" .$fetch['replies']. " Replies</i>";
        $list .= " (<i>Last post by: " .$fetch['lastposter']. "</i>)<br /><hr width=\"50\"><br />";
    
    }
    //output
    echo $list;
    
?>
</body>
</html> 
You could always use a RSS feed: http://nowitsmybb.com/tutorials/display-...-with-rss/. Also moved thread to a more appropriate forum. This is not related to MyBB General Support.
Pages: 1 2