This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Random Comments v.3.4
#1

Hello,

I have a Licence and Extractor.
How to display not Newest Comments, but Random 5 comments at sidebar of my website?

At extractor, I have changed this:


public function newestComments()
{
$html = '';

$comments = mysqli_query($this->getLink(), "SELECT `id` FROM `" . CMTX_DB_PREFIX . "comments` WHERE `is_approved` = '1' ORDER BY `date_added` DESC LIMIT 8");


to:

public function randomComments()
{
$html = '';

$comments = mysqli_query($this->getLink(), "SELECT `id` FROM `" . CMTX_DB_PREFIX . "comments` WHERE `is_approved` = '1' ORDER BY `date_added` DESC LIMIT 5");


However, I stiil got problems:
Fatal error: Cannot redeclare extractor:: substr() in /home/var/...domain/ets/
Fatal error: Cannot redeclare extractor:: shortenComment() in /home


At example file I have changed:

<?php $cmtx_folder = '/main/'; require_once $_SERVER['DOCUMENT_ROOT'] . '/main/extractor.php'; $extractor = new extractor($cmtx_folder); if ($extractor->isConnected()) {echo $extractor->randomComments();}?>

Please help Steven!
Reply
#2

According to the error you've duplicated the substr() and shortenComment() methods. In other words you have two substr() methods and two shortenComment() methods in the file. There should only be one of each method, so just remove the duplicates.

Then in your randomComments() method, you would just need to change:

Code:
ORDER BY `date_added` DESC

to

Code:
ORDER BY RAND()

Have you completed the interview?
Reply
#3

Thank you much, for help!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Tim
06-Jan-2021, 08:56 PM
Last Post by Gevill
23-Jul-2019, 01:17 AM
Last Post by Steven
16-Feb-2018, 09:15 AM
Last Post by Steven
09-Jan-2015, 10:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)