MyBB Hacks

Full Version: SQL Error While Filtering
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am getting an SQL while filtering my threads by a custom field. I have the exact same setup on another board which is version 1.8.21 as the board im working now which is version 1.8.22. I dont know if this update has something to do with it or not.

The forum im making is a marketplace forum for online accounts. I have a field called trdfplat which holds the value for which platform the account is on (xbox, ps4, etc.). This is the SQL error im recieving.

SQL Error:
1054 - Unknown column 'tfd.trdfplat' in 'where clause'
Query:
SELECT COUNT(tid) AS threads FROM mybb_threads t WHERE fid = '36' AND (t.visible IN (1,-1,0)) AND tfd.`trdfplat` IN ("Xbox")

Any help would be great! Thank you.
Hi,
any solution, yet? I have the same issue on 1.8.22 (using the Link Directory).
Cheers!
Full error:

<error>
<dateline>1578505893</dateline>
<script></script>
<line>0</line>
<type>20</type>

<friendly_type>MyBB SQL Error</friendly_type>

<message>SQL Error: 1054 - Unknown column 'tfd.xtldcat' in 'where clause'
Query: SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  </message>

<back_trace>#0  errorHandler->log_error(20, SQL Error: 1054 - Unknown column 'tfd.xtldcat' in 'where clause'
Query: SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  , , 0) called at [/hp/bv/ab/cf/www/forum-url/inc/class_error.php:189]
#1  errorHandler->error(20, Array ([error_no] => 1054,[error] => Unknown column 'tfd.xtldcat' in 'where clause',[query] => SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  )) called at [/hp/bv/ab/cf/www/forum-url/inc/db_mysqli.php:597]
#2  DB_MySQLi->error(SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  ) called at [/hp/bv/ab/cf/www/forum-url/inc/db_mysqli.php:337]
#3  DB_MySQLi->query(SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  , 0, 0) called at [/hp/bv/ab/cf/www/forum-url/inc/plugins/xthreads.php(878) : eval()'d code:8]
#4  _objcont_3->query(SELECT COUNT(tid) AS threads FROM iioc_threads t WHERE fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  ) called at [/hp/bv/ab/cf/www/forum-url/inc/db_mysqli.php:789]
#5  DB_MySQLi->simple_select(threads t, COUNT(tid) AS threads, fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  , Array ()) called at [/hp/bv/ab/cf/www/forum-url/inc/plugins/xthreads.php(878) : eval()'d code:24]
#6  _objcont_6->simple_select(threads t, COUNT(tid) AS threads, fid = '44'  AND (t.visible IN (1,-1,0)) AND tfd.`xtldcat` IN ("Filter-word")  ) called at [/hp/bv/ab/cf/www/forum-url/forumdisplay.php:610]
</back_trace>
</error>
I've spent basically no time on this, but a very quick look at the code, perhaps the following change may work.

In inc/xthreads/xt_forumdhooks.php, find:

PHP Code:
$table == "threads"

replace with

PHP Code:
($table == "threads" || $table == "threads t")


Otherwise I'll try to find some time to look into this more.

Fantastic!

That did the job.

Thanks for the great support, ZiNgA BuRgA
Thanks for confirming.  I'll probably need to spend some time to see if there's other issues due to changes in newer versions of MyBB.
hello

i have the same problem after testing the job portal modified  on my website

SQL Error:
1054 - Unknown column 'tfd.xtjpcat' in 'where clause'
Query:
SELECT COUNT(tid) AS threads FROM mybbq6_threads t WHERE fid = '4' AND (t.visible IN (1)) AND tfd.`xtjpcat` IN ("surencheres")

i go to the "xt_forumdhooks.php" page and see the line

$dbt = '
static $done_t = false;
if(!$done_t && ($table == "threads" || $table == "threads t") && $fields == "COUNT(tid) AS threads") {
$done_t = true;
$table = "threads t LEFT JOIN {$this->table_prefix}threadfields_data tfd ON t.tid=tfd.tid";
$fields = "COUNT(t.tid) AS threads";
$conditions = xthreads_forumdisplay_filter_fixqcond($conditions);
$options = array("limit" => 1);
}
';

what's the problem?

cordially[/i]
Same problem but with ZiNgA BuRgA's edit it works again.

Thank you Yipi
Reference URL's