Results 1 to 4 of 4

Thread: latesttopics.php error on sort by "rating"

  1. #1
    Join Date
    Dec 2005
    Posts
    5

    Default latesttopics.php error on sort by "rating"

    Hi I've come across what I believe is a bug in lastesttopics.php when you use the "Thread Display Order" => "Rating" the following error is returned:

    Code:
    Database error in vBulletin 3.5.2:
    
    Invalid SQL:
    
    				SELECT
    				
    				thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
    				
    				FROM vb_thread as thread
    				LEFT JOIN vb_deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
    				WHERE open != 10 AND thread.visible = 1
    				
    				
    				
    				AND deletionlog.primaryid IS NULL
    				ORDER BY voteavg DESC
    				LIMIT 5;
    
    MySQL Error  : Unknown column 'voteavg' in 'order clause'
    Error Number : 1054
    the affected code is on line 79 (or perhaps 133 if a divide by zero error?) here is line 77,78, & 79:

    Code:
                    $threads = $db->query_read("
                                    SELECT
                                    " . iif($mod_options['portal_threads_showrating'], 'IF(votenum >= ' . $vbulletin->options['showvotes'] . ', votenum, 0) AS n
    umbvote, IF(votenum >= ' . $vbulletin->options['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
    (might I add some pretty funny looking "if" statements!!) Anyone have some info to get this fixed would be much appreciated! Thanks,

    John

  2. #2
    Join Date
    Dec 2005
    Posts
    5

    Default Re: latesttopics.php error on sort by "rating"

    Can someone else see if they can duplicate this? Perhaps it is due to the fact that some of my threads do not have any ratings? ...trying to figure it out still

  3. #3
    Join Date
    Dec 2005
    Posts
    5

    Default Re: latesttopics.php error on sort by "rating"

    I solved it. It actually is a bug, but not very hard to fix. YOU MUST HAVE "Show Thread Ratings" set to "yes" or you get the error. The code probably need a sanity check here to prevent the unknowing user from encountering the same error. Anyways - I have sort by rating now working.. no help like self help LOL

    -John

  4. #4
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default Re: latesttopics.php error on sort by "rating"

    Thanks for pointing that out. If you'd like to correct the problem without turning on the ratings display, just look in your modules/latesttopics.php file for this code:
    PHP Code:
    iif($mod_options['portal_threads_showrating'
    Replace with this:
    PHP Code:
    iif($mod_options['portal_threads_showrating'] OR $mod_options['portal_threads_orderby'] == 'voteavg' 
    And that should take care of the problem.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Newbie: Missing the "Home" and "Register" in the top Navigation
    By Perkyd in forum Troubleshooting / "How do I..." Questions
    Replies: 2
    Last Post: 09-25-2005, 11:19 PM
  2. Latest Topics - Combine "Show New Posts" with "Goto New Post"
    By Tom M in forum Add-On Modules & Modifications
    Replies: 2
    Last Post: 08-08-2005, 11:10 AM
  3. Replies: 0
    Last Post: 04-18-2005, 11:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •