News Article List Isn't Showing?

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
hey guys, i went back to revcms a few months ago (@JMG helped) and my news list doesn't show up? it's my old cms from 2018/2019 though but my previous articles where made on braincms could that e the reason?

You must be registered for see images attach
 

kailani

Member
Sep 26, 2020
30
12
You're probably not fetching it correctly from the database, post the code you're using to fetch it from the database and your current schema and data from your news tables.
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
You're probably not fetching it correctly from the database, post the code you're using to fetch it from the database and your current schema and data from your news tables.
PHP:
<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="shortcut icon" href="{url}/app/tpl/skins/{skin}/images/favicon.ico" type="image/vnd.microsoft.icon"/>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>{hotelName} - News Articles</title>

        <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/common.css?<?= time(); ?>" type="text/css">
        <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs2.js"></script>
        <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/visual.js"></script>
        <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs.js"></script>
        <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/common.js"></script>
        <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/fullcontent.js"></script>

        <script type="text/javascript">
            document.habboLoggedIn = true;
            var habboName = "{username}";
            var habboId = {userid};
            var habboReqPath = "";
            var habboStaticFilePath = "{url}/app/tpl/skins/Habbo";
            var habboImagerUrl = "http://www.habbo.com/habbo-imaging/";
            var habboPartner = "";
            var habboDefaultClientPopupUrl = "{url}/client";
            window.name = "habboMain";
            if (typeof HabboClient != "undefined") {
                HabboClient.windowName = "eac955c8dbc88172421193892a3e98fc7402021a";
                HabboClient.maximizeWindow = true;
            }
        </script>

        <!--[if IE 8]>
            <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie8.css" type="text/css">
        <![endif]-->
        <!--[if lt IE 8]>
            <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie.css" type="text/css" />
        <![endif]-->
        <!--[if lt IE 7]>
            <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie6.css" type="text/css" />
            <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/pngfix.js"></script>
            <script type="text/javascript">
                try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
            </script>
            <style type="text/css">
                body { behavior: url({url}/app/tpl/skins/Habbo/js/csshover.htc); }
            </style>
        <![endif]-->
    </head>

    <body id="news">

        <div id="overlay"></div>
             <?php include ("includes/header.php"); ?>
                <ul id="navi">
                    <li class="metab"><a href="{url}/me">{username}</a><span></span></li>
                    <li class="selected"><strong>Community</strong><span></span></li>
                    <li id="tab-register-now"><a href="{url}/store">Store</a><span></span></li>
                    <?php
                    if(isset($_SESSION['user']['id']))
                    if(mysql_result(mysql_query("SELECT rank FROM users WHERE id = '" . $_SESSION['user']['id'] . "'"), 0) >= 3)                    {
                    echo '<li id="tab-register-now"><a href="{url}/allseeingeye/index.php" target="_blank">Staff Panel</a><span></span></li>';
                    }
                    ?>
                </ul>
                <div id="habbos-online"><div id="content"><div class="cbb "><span><b>{online}</b><br>users<br>online</span></div></div></div>
            </div>
        </div>
        <div id="content-container">
            <div id="navi2-container" class="pngbg">
                <div id="navi2" class="pngbg clearfix">
                    <ul>
                        <li class=""><a href="{url}/community">Community</a></li>
                        <li class="selected">News</li>
                        <li class=""><a href="{url}/staff">{hotelname} Staff</a></li>
                        <li class=""><a href="{url}/topstats">Top Player Stats</a></li>
                        <li class=""><a href="{url}/trusteddealers">Trusted Dealers</a></li>
                        <li class=""><a href="{url}/stats">{hotelname} Statistics</a></li>
                    </ul>
                </div>
            </div>
            <div id="container">
                <div id="content" style="position: relative" class="clearfix">
                    <div id="column1" class="column">
                        <div class="habblet-container ">
                            <div class="cbb clearfix red ">
                                <h2 class="title">News Articles</h2>
                                <div id="article-archive">
                                    <ul>
                                        <?php
    {
    for ($i = 0; $i < 6; $i++)
        {
            $sectionName = "";
            $sectionCutoffMax = 0;
            $sectionCutoffMin = 0;

            switch ($i)
            {
                    case 0:

                            $sectionName = 'Today';
                            $sectionCutoffMax = time();
                            $sectionCutoffMin = time() - 86400;
                            break;

                    case 1:

                            $sectionName = 'Yesterday';
                            $sectionCutoffMax = time() - 86400;
                            $sectionCutoffMin = time() - 172800;
                            break;

                    case 2:

                            $sectionName = 'This week';
                            $sectionCutoffMax = time() - 172800;
                            $sectionCutoffMin = time() - 604800;
                            break;

                    case 3:

                            $sectionName = 'Last week';
                            $sectionCutoffMax = time() - 604800;
                            $sectionCutoffMin = time() - 1209600;
                            break;

                    case 4:

                            $sectionName = 'This month';
                            $sectionCutoffMax = time() - 1209600;
                            $sectionCutoffMin = time() - 2592000;
                            break;

                    case 5:

                            $sectionName = 'Last month';
                            $sectionCutoffMax = time() - 2592000;
                            $sectionCutoffMin = time() - 5184000;
                            break;
            }

            $q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax .  " ORDER BY published DESC";
            $getArticles = mysql_query($q);
            if (mysql_num_rows($getArticles) > 0)
            {
                    echo '<br>';
                    echo '<h2>' . $sectionName . '</h2>';

                    while ($a = mysql_fetch_assoc($getArticles))
                    {
                        if($a['id'] == $_GET['id'])
                        {
                        echo '' . $a['title'] . '&nbsp;&raquo;';
                        }
                        else
                        {
                        echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . '&nbsp;&raquo;</a></li>';
                        }
                    }
            }
        }
    }
?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
                    <div id="column2" class="column">
                        <div class="habblet-container ">
                            <div class="cbb clearfix notitle ">
                                <div id="article-wrapper">
                                    <h2>{newsTitle} - By: {newsAuthor}</h2>
                                    <div class="article-meta">Posted {newsDate}
                                    </div>
                                    <div class="article-body">
                                        {newsContent}
                                        <br><br>
                                        <script type="text/javascript" language="Javascript">
                                            document.observe("dom:loaded", function() {
                                                $$('.article-images a').each(function(a) {
                                                    Event.observe(a, 'click', function(e) {
                                                        Event.stop(e);
                                                        Overlay.lightbox(a.href, "Image is loading");
                                                    });
                                                });

                                                $$('a.article-2729').each(function(a) {
                                                    a.replace(a.innerHTML);
                                                });
                                            });
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
</div> </div> </div> </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                        </div>
                    </div>
            <script type="text/javascript">
                document.observe('dom:loaded', function() {
                    CurrentRoomEvents.init();
                });
            </script>
        </div>

        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
        <script type="text/javascript">
            HabboView.run();
        </script>

        <!--[if lt IE 7]>
            <script type="text/javascript">
                Pngfix.doPngImageFix();
            </script>
        <![endif]-->


            <?php include('includes/footer.php'); ?>
            <?php include('includes/checktheban.php'); ?>


    </body>
</html>
that's the whole page code
 

kailani

Member
Sep 26, 2020
30
12
My guess is that its something to do with this part, maybe your schema isn't matching up - Post your cms_news schema and data
Code:
if (mysql_num_rows($getArticles) > 0)
{
        echo '<br>';
        echo '<h2>' . $sectionName . '</h2>';

        while ($a = mysql_fetch_assoc($getArticles))
        {
            if($a['id'] == $_GET['id'])
            {
            echo '' . $a['title'] . '&nbsp;&raquo;';
            }
            else
            {
            echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . '&nbsp;&raquo;</a></li>';
            }
        }
}
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
My guess is that its something to do with this part, maybe your schema isn't matching up - Post your cms_news schema and data
Code:
$q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax .  " ORDER BY published DESC";
$getArticles = mysql_query($q);
if (mysql_num_rows($getArticles) > 0)
{
        echo '<br>';
        echo '<h2>' . $sectionName . '</h2>';

        while ($a = mysql_fetch_assoc($getArticles))
        {
            if($a['id'] == $_GET['id'])
            {
            echo '' . $a['title'] . '&nbsp;&raquo;';
            }
            else
            {
            echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . '&nbsp;&raquo;</a></li>';
            }
        }
}
too long to posted, i've put it here
 

kailani

Member
Sep 26, 2020
30
12
Your query isn't returning any rows (at least not for the first iteration)

This is the raw SQL (time() was ran on UTC):
Code:
SELECT * FROM cms_news WHERE published >= 1601386430 AND published <= 1601300030  ORDER BY published DESC

If you check this, it should return 1555679681
Code:
SELECT MIN(published) FROM `cms_news`;
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
Your query isn't returning any rows (at least not for the first iteration)

This is the raw SQL (time() was ran on UTC):
Code:
SELECT * FROM cms_news WHERE published >= 1601386430 AND published <= 1601300030  ORDER BY published DESC
so where do i put that? o.o
 

kailani

Member
Sep 26, 2020
30
12
Your code seems fine to me, its your timestamps that are the issue. If you select the maximum published date (most recent article), you'll get 1595509353 (unix) which if you convert to a DateTime is 07/23/2020 @ 1:02pm (UTC)

Run this and confirm you get 1595509353:
Code:
SELECT MAX(published) FROM `cms_news`;

If you're saying you have posted an article since 07/23/2020 @ 1:02pm (and since you sent the schema + data to me) and it still isn't showing up, share the code for your INSERT when creating a new news article and I can take a look.
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
Your code seems fine to me, its your timestamps that are the issue. If you select the maximum published date (most recent article), you'll get 1595509353 (unix) which if you convert to a DateTime is 07/23/2020 @ 1:02pm (UTC)

Run this and confirm you get 1595509353:
Code:
SELECT MAX(published) FROM `cms_news`;
yep i get 1595509353
 

kailani

Member
Sep 26, 2020
30
12
yep i get 1595509353
Great, so we're on the same page. What this query returns is, the published date (in unix timestamp form) for the most recent article you have created in your database. Try creating an article now and seeing if it shows up, if it doesn't then share the `published` column value for the new article with me and I can take a look, chances are if that happens is that you aren't setting the correct timestamp upon creation.
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
Great, so we're on the same page. What this query returns is, the published date (in unix timestamp form) for the most recent article you have created in your database. Try creating an article now and seeing if it shows up, if it doesn't then share the `published` column value for the new article with me and I can take a look, chances are if that happens is that you aren't setting the correct timestamp upon creation.
no it doesn't show when i create a new one either

that's the structure of the cms_news

Code:
DROP TABLE IF EXISTS `cms_news`;
CREATE TABLE `cms_news` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `image` varchar(100) NOT NULL DEFAULT '0',
  `shortstory` text NOT NULL,
  `longstory` text NOT NULL,
  `date` int(11) NOT NULL DEFAULT '0',
  `type` varchar(100) NOT NULL DEFAULT '1',
  `roomid` varchar(100) NOT NULL DEFAULT '1',
  `updated` enum('0','1') NOT NULL DEFAULT '0',
  `published` int(10) DEFAULT '0',
  `author` varchar(255) NOT NULL DEFAULT 'Bran',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1;
 

kailani

Member
Sep 26, 2020
30
12
Can you check if it definitely created the row in your cms_news table? If so, please share the data for just that one row with me, or even better just the value of published column.
 

kailani

Member
Sep 26, 2020
30
12
It should be a number if that helps, just open your table and look for the "published" column, and paste the value.

If you can't work out how to do that, run this query and it should give you the value:
Code:
SELECT published FROM cms_news ORDER BY id DESC LIMIT 1;
 

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
It should be a number if that helps, just open your table and look for the "published" column, and paste the value.

If you can't work out how to do that, run this query and it should give you the value:
Code:
SELECT published FROM cms_news ORDER BY id DESC LIMIT 1;
1601383989
 

kailani

Member
Sep 26, 2020
30
12
From what I saw on your screen, you are checking the same timestamp, which will obviously return 0 rows.

A dump of your PHP string (the query you run):
Code:
SELECT * FROM cms_news WHERE published >= 1601300030 AND published <= 1601300030 ORDER BY published DESC

I'm not sure what code you posted to me, but I don't think that's what your actual code looks like.

Code:
sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;


Which from my time() becomes
Code:
$sectionCutoffMax = 1601390219
$sectionCutoffMin = 1601303819


The query (it returns your news articles):
Code:
SELECT * FROM cms_news WHERE published >= 1601390219 AND published <= 1601303819 ORDER BY published DESC

Everything above is based only on the first iteration, but from my perspective, it should work with the code you posted and the data in your tables.
 
Last edited:

Bran

mediocre graphics artist
Mar 13, 2017
1,728
1,533
From what I saw on your screen, you are checking the same timestamp, which will obviously return 0 rows.

A dump of your PHP string (the query you run):
Code:
SELECT * FROM cms_news WHERE published >= 1601300030 AND published <= 1601300030 ORDER BY published DESC

I'm not sure what code you posted to me, but I don't think that's what your actual code looks like.

Code:
sectionCutoffMax = time();
$sectionCutoffMin = time() - 86400;


Which from my time() becomes
Code:
$sectionCutoffMax = 1601390219
$sectionCutoffMin = 1601303819


The query (it returns your news articles):
Code:
SELECT * FROM cms_news WHERE published >= 1601390219 AND published <= 1601303819 ORDER BY published DESC

Everything above is based only on the first iteration, but from my perspective, it should work with the code you posted and the data in your tables.
that's my news.php lol
 

Users who are viewing this thread

Top