PDA

View Full Version : SQL Error - Need Help


sunilvarma
03-03-2010, 04:56 AM
I have a plugin with the following code:

###hack
if ($vbulletin->userinfo['permissions']['cispermissions'] & $vbulletin->bf_ugp_cispermissions['can_thread']) {

$user_ig = $vbulletin->db->query_read("SELECT threadid from ". TABLE_PREFIX ."cis_thread_ignore where userid = " . $vbulletin->userinfo['userid'] . " and ig_type = 'thread'");

while ($ignores = $vbulletin->db->fetch_array($user_ig)) {

$ignored .= "$ignores[threadid], ";

}

if ($ignored != '') { $ignored = substr($ignored, 0, -2); $globalignore .= $hook_query_where .= " AND thread.threadid NOT IN($ignored)"; }

if ($vbulletin->userinfo['cis_ignorelist_ignore']) {

$ignore_users = preg_replace('#\s+#s', ',', $vbulletin->userinfo['ignorelist']);

if ($ignore_users != '') {

$hook_query_where .= " AND thread.postuserid NOT IN($ignore_users)";

}

}

}

if ($vbulletin->userinfo['permissions']['cispermissions'] & $vbulletin->bf_ugp_cispermissions['can_ignore_tag']) {

if ($vbulletin->userinfo['cis_ignoretags_ignore'] != '') {

require_once(DIR . '/includes/functions_newpost.php');

include_once(DIR . '/cis_includes.php');

$tags = fetch_valid_tags('',split_tag_list($vbulletin->userinfo['cis_ignoretags_ignore']), $errors);

foreach ($tags as $item) {

$tag = $db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "tag
WHERE tagtext = '" . $db->escape_string($item) . "'");

if ($tag['tagid'] != '') {

$tagged[$tag[tagid]] = $tag[tagid];

}


}

if (!empty($tagged)) {

foreach ($tagged as $tag) {

$dotags = $vbulletin->db->query_read("SELECT contentid from ". TABLE_PREFIX ."tagcontent where tagid = $tag");

while ($igs = $vbulletin->db->fetch_array($dotags)) {

$ignore_tags .= "$igs[threadid], ";

}
}

}

if ($ignore_tags != '') {

$ignore_tags = substr($ignore_tags, 0, -2);

$hook_query_where .= " AND thread.threadid NOT IN ($ignore_tags)";

}

}

}

###

It's causing the following DB error:


Database error in vBulletin 4.0.2:

Invalid SQL:

SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > 1267592343 AND open <> 10, 1, 0)) AS newthread

FROM thread AS thread


WHERE forumid = 2
AND sticky = 0

AND visible = 1



AND thread.threadid NOT IN ();

MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 13
Error Number : 1064
Request Date : Wednesday, March 3rd 2010 @ 01:55:07 AM
Error Date : Wednesday, March 3rd 2010 @ 01:55:07 AM
Script : http://localhost/vb40/forumdisplay.php?2-Main-Forum
Referrer : http://localhost/vb40/
IP Address : 127.0.0.1
Username : test1
Classname : vB_Database
MySQL Version :

Any help would be appreciated.

Thanks
Sunil

ChopSuey
03-03-2010, 12:09 PM
You can view: Getting error 1064? (https://vborg.vbsupport.ru/showthread.php?t=72003)

Hope that helps.

sunilvarma
03-03-2010, 04:37 PM
I tried that but it doesn't help.

This same plugin actually runs in vB 3.7 without any issues. So, I think there's some code that's changed in vB 4 that's causing the error?

Thanks

--------------- Added 1267661475 at 1267661475 ---------------

figured it out.

the tagthread table in vb 3.7 is changed to tagcontent in vB 4. I changed that in the query but I overlooked the part where the code's still looking for threadid (3.7) instead of contentid (4.0)