UBB.Dev
Posted By: Kordegnen Simple news box ?? - 02/24/2003 6:47 PM
On my indexpage i want a simple newsbox that takes the latest post i a specific forum and puts it in to my sidebar on my indexpage..

do i have to install IIP just to do this one thing ??

thomas
www.venuslogen.dk
Posted By: JoshPet Re: Simple news box ?? - 02/24/2003 6:50 PM
There is a ubbtnews.php script included in the "addons" directory of your threads install. That should do what you need.
Posted By: Kordegnen Re: Simple news box ?? - 02/25/2003 12:49 PM
HI josh

Found it and its working great ;O)

Found also an topthreads script, but cant get it to work ??

i get this error
Warning: Supplied argument is not a valid MySQL result resource in /www/sites/4701.dk/httpdocs/ubbthreads/mysql.inc.php on line 130

the code is looking like this

Code
 <? <br />/* <br /># UBB.threads, Version 6 <br /># Official Release Date for UBB.threads Version6: 06/05/2002 <br /> <br /># First version of UBB.threads created July 30, 1996 (by Rick Baker). <br /># This entire program is copyright Infopop Corporation, 2002. <br /># For more info on the UBB.threads and other Infopop <br /># Products/Services, visit: http://www.infopop.com <br /> <br /># Program Author: Rick Baker. <br /> <br /># You may not distribute this program in any manner, modified or otherwise, <br /># without the express, written written consent from Infopop Corporation. <br /> <br /># Note: if you modify ANY code within UBB.threads, we at Infopop Corporation <br /># cannot offer you support-- thus modify at your own peril :) <br /># --------------------------------------------------------------------------- <br />*/ <br /> <br />// ------------------------------------------------- <br />// Variables Section - Edit these to suit your needs <br /> <br />  // Path to your main.inc.php script <br />   $path = "/www/sites/4701.dk/httpdocs/ubbthreads/"; <br /> <br />  // Top threads by "views" or by "replies" <br />   $topthreads =	"replies"; <br /> <br />  // Post age threshold.  How many days old can a thread be and still make <br />  // the list <br />   $threadage =	7; <br /> <br />  // Set this variable to the total number of threads that you wish to show <br />   $totalthreads = 	3; <br /> <br />  // This varialbe will affect the way the thread is listed.  Set this to none <br />  // and it will only show the thread Subject, with a link pointing to the <br />  // item on the board.  Set it to "full" and it will show the body of the <br />  // item below the subject.  Set it to a number and it will show <br />  // that many characters of the body with the subject clickable to read the <br />  // full item. <br />   $threadbody = 	'none'; <br /> <br />  // The url to your UBB.threads installation <br />   $forumurl = 	"http://www.4701.dk/ubbthreads/"; <br /> <br />  // Include the date when the news was posted <br />   $includedate = 	"no"; <br /> <br />  // Include who it was posted by <br />   $includewho = 	"no"; <br /> <br />  // You may need to change the unshift line to the path of your UBB.threads <br />  // installation <br /> <br />// ----------------------------- <br />// End of the variables section <br />   require ("$path/main.inc.php"); <br /> <br />// ------------------- <br />// Setup the variables <br />   $html = new html; <br />   $date = $html -> get_date(); <br />   $date = $date - ($threadage * 86400); <br /> <br />   $sort; <br />   if ($topthreads == "views") { <br />      $sort = "t1.B_Counter"; <br />   } <br />   else { <br />      $sort = "t1.B_Replies"; <br />   } <br /> <br />// -------------------------- <br />// Let's grab the news items <br />   $query = " <br />    SELECT t1.B_Number,t1.B_Posted,t1.B_Last_Post,t2.B_Username,t1.B_Subject,t1.B_Body,t1.B_Main,t1.B_Replies,t1.B_Counter,t1.B_Board <br />    FROM  {$config['tbprefix']}Posts AS t1, <br />          {$config['tbprefix']}Users AS t2 <br />    WHERE t1.B_Number = t1.B_Main <br />    AND   t1.B_Last_Post > '$date' <br />    AND   t1.B_PosterId = t2.U_Number <br />    ORDER BY $sort DESC <br />    LIMIT $totalthreads <br />   "; <br />   $sth = $dbh -> do_query($query); <br /> <br />// --------------------------- <br />// echo out the starting html <br />   echo "<DL>"; <br /> <br />// ----------------------- <br />// Cycle through the posts <br />   while ( list($Number,$Posted,$Last,$Username,$Subject,$Body,$Main,$Replies,$Counter,$Keyword) = $dbh -> fetch_array($sth)) { <br /> <br />   // --------------------------------- <br />   // Set up the variables for echoing <br />      $date = $html -> convert_time($Posted); <br />      if ($threadbody == "none") { <br />         $Body = ""; <br />         $Subject = "<a href=\"$forumurl/showflat.php?Board=$Keyword&Number=$Number\">$Subject</a>"; <br />      } <br />      if (ereg("[0123456789]",$threadbody)) { <br />         $Body =substr($Body,0,$threadbody); <br />         $Body .="..."; <br />         $Subject = "<a href=\"$forumurl/showflat.php?Board=$Keyword&Number=$Number\">$Subject</a>"; <br />      } <br />      if ($includedate == "yes") { <br />         $date = "<br>Posted on $date"; <br />      } <br />      else { <br />         $date = ""; <br />      } <br />      if ($includewho == "yes") { <br />         $Username = "<br>Posted by $Username"; <br />      } <br />      else { <br />         $Username = ""; <br />      } <br /> <br />   // ------------------------------- <br />   // The actual HTML that is put out <br />      echo " <br />        <b><font face=\"Verdana\" size=\"2\" color=\"#FFffff\">Top Indlæg</font></b><br> <br />    <table><tr><td width= 100% bgcolor= #CBCDCD ><DT><font size=2><b>$Subject</b> <br />        $date <br />        $Username <br />        <DD>$Body <br />      "; <br /> <br />  // --------------- <br />  // End of the HTML <br /> <br />   } <br />   echo "</DL><td></tr></table>"; <br />   $dbh -> finish_sth($sth); 
Posted By: JoshPet Re: Simple news box ?? - 02/25/2003 5:21 PM
You might need to comment out this line:

require ("$path/main.inc.php");


As you only need to require manin.inc.php once per page.

Hope that helps.
Posted By: Kordegnen Re: Simple news box ?? - 02/26/2003 2:34 PM
if i do that i get this error

Fatal error: Cannot instantiate non-existent class: html in /www/sites/4701.dk/httpdocs/ubbthreads/addons/ubbttopthreads.php on line 63


thomas
Posted By: Dave_L_dup1 Re: Simple news box ?? - 02/26/2003 2:44 PM
1) Warning: Supplied argument is not a valid MySQL result resource

That's a secondary error. It usually means that a previous MySQL query failed. Do any other errors show up in your MySQL error log?

2) Instead of removing the require, try replacing it with require_once.
Posted By: gaper_dup1 Re: Simple news box ?? - 02/28/2003 12:20 AM
i'm getting the same error...i tried the changes...am trying to get access to the MYSQL error log to get more info.

does anybody have this working?

thanks,
jerad
© UBB.Developers