Current time: 01-09-2009, 03:15 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Latest threads/posts on your site
08-24-2008, 09:35 PM
Post: #11
RE: Latest threads/posts on your site
I'm still getting Parse error: syntax error, unexpected '{' in /home/hu/public_html/MyBBLatest.class.php on line 13

Why the { kill it anyway?

Quacktacular Medias
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 09:50 PM
Post: #12
RE: Latest threads/posts on your site
it's impossible to get this error. you had to made a mistake while copying class content. please, give me 13 line of your class file.

Marines Blog - my techblog
Polish MyBB Support
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 09:54 PM (This post was last modified: 08-24-2008 09:55 PM by quacktacular.)
Post: #13
RE: Latest threads/posts on your site
I would hope so, but it doesn't look I have.

Line 13:
Code:
class MyBBLatest {

Full code:
Code:
<?php
/**
* This class can display latest threads or posts
* formated in unordered list (<ul/>)
* It doesn't depend on place where script is being run
* just initialize class and execute proper method

* @author Mariusz "marines" Kujawski <marinespl@gmail.com>
* @link http://marines.jogger.pl/
* @version 0.1
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
class MyBBLatest {
   // mysql db handler
   private $db;
   // tables prefix
   private $prefix;
   // url to mybb
   private $url;
   /**
   * constructor
   *
   * @param string $mybb path to MyBB instalation
   * @param string $url URL of MyBB instalation
   * @return boolean
   */
   public function __construct($mybb = '', $url) {
      // include mybb config file
      @include('./' . $mybb . 'inc/config.php');
      // db connect
      $this->db = @mysql_connect($config['database']['hostname'], $config['database']['username'], $config['database']['password']);
      // db choose
      @mysql_select_db($config['database']['database'], $this->db);
      // stop executing if db connection isn't availible
      if (!$this->db) return false;
      // set db prefix
      $this->prefix = $config['database']['table_prefix'];
      // set base url of mybb
      $this->url = $url;
      // return
      return true;
   }
   /**
   * display latest threads
   *
   * @param integer $many indicates how many threads have to be retrieved from database
   * @param boolean $lastpost indicates whether link has to direct to last post in thread
   * @param integer $fid ID of forum which threads have to be retrieved from
   * @return string list of threads
   */
   public function threads($many = 10, $lastpost = false, $fid = false) {
      // forum id select
      if ($fid) {
         $where = 'WHERE `fid` = ' . $fid;
      }
      if ($lastpost) {
         $last = '&action=lastpost';
      }
      // initialize temporary var
      $tmp = '<ul class="last-threads">';
      // select data
      $query = @mysql_query('SELECT `tid`, `subject` FROM `' . $this->prefix . 'threads` ' . $where . ' ORDER BY `dateline` DESC LIMIT ' . $many);
      // check if query has result
      if (!$query) return false;
      // collect data into list
      while ($row = mysql_fetch_array($query)) {
         $tmp .= '<li><a href="' . $this->url . 'showthread.php?tid=' . $row[0] . $last . '">' . $row[1] . '</a></li>';
      }
      $tmp .= '</ul>';
      // return list of threads
      return $tmp;
   }
   /**
   * display latest posts
   *
   * @param integer $many indicates how many posts have to be retrieved from database
   * @param integer $fid ID of forum which posts have to be retrieved from
   * @return string list of posts
   */
   public function posts($many = 10, $fid = false) {
      // forum id select
      if ($fid) {
         $where = 'WHERE `fid` = ' . $fid;
      }
      // initialize temporary array
      $tmp = '<ul class="last-threads">';
      // select db data
      $query = @mysql_query('SELECT `pid`, `tid`, `subject` FROM `' . $this->prefix . 'posts` ' . $where . ' ORDER BY `dateline` DESC LIMIT ' . $many);
      // check if query has result
      if (!$query) return false;
      // collect data into list
      while ($row = mysql_fetch_array($query)) {
         $tmp .= '<li><a href="' . $this->url . 'showthread.php?tid=' . $row[1] . '&pid=' . $row[0] . '#pid' . $row[0] . '">' . $row[2] . '</a></li>';
      }
      $tmp .= '</ul>';
      // return posts
      return $tmp;
   }
} // MyBBLatest end
?>

Quacktacular Medias
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 09:56 PM
Post: #14
RE: Latest threads/posts on your site
i'm so confused. Sad which PHP version do you have?

Marines Blog - my techblog
Polish MyBB Support
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 09:58 PM
Post: #15
RE: Latest threads/posts on your site
Me too.. I have 5.2.5.

Quacktacular Medias
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 10:26 PM
Post: #16
RE: Latest threads/posts on your site
i really have no idea Sad

Marines Blog - my techblog
Polish MyBB Support
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2008, 10:32 PM
Post: #17
RE: Latest threads/posts on your site
Where am I supposed to put the class? Its on my website's account right now, not the forum. How should I specify the path to inc/config.php?

You're can have account access is you think it'll help.

Quacktacular Medias
Visit this user's website Find all posts by this user
Quote this message in a reply
08-25-2008, 09:21 PM
Post: #18
RE: Latest threads/posts on your site
Good work, marines! Works very well for me!
Find all posts by this user
Quote this message in a reply
10-09-2008, 01:07 AM
Post: #19
RE: Latest threads/posts on your site
Hi there,

I have a wordpress blog in the root (eg: mysite.com) and I have the mybb forum in a subdomain (eg: forums.mydomain.com). I want to show the latest mybb forum posts in my wordpress sidebar. I have tried this and other topics but nothing helped. I also posted it in the support forums but nobody replied.

Please help how to show the last mybb forum posts in my wordpress sidebar.
Find all posts by this user
Quote this message in a reply
10-10-2008, 07:25 PM
Post: #20
RE: Latest threads/posts on your site
just edit "sidebar" template and use code from the examples somewhere between "<?php" and "?>" tags. AFAIK wordpress's templates allow PHP in their content.

Marines Blog - my techblog
Polish MyBB Support
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: