vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   SQL Error - Need Help (https://vborg.vbsupport.ru/showthread.php?t=237348)

sunilvarma 03-03-2010 04:56 AM

SQL Error - Need Help
 
I have a plugin with the following code:

PHP 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($ignored0, -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_tags0, -2);

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

    }

}

### 

It's causing the following DB error:


Code:

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?

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 [DATE]1267661475[/DATE] at [TIME]1267661475[/TIME] ---------------

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)


All times are GMT. The time now is 09:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01094 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete