vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   thread and reply count (https://vborg.vbsupport.ru/showthread.php?t=41235)

dinozz 07-18-2002 07:12 PM

thread and reply count
 
Hello, i tried to make an hack to count the number of threads and replies of every member of my forum.
I tried to do that with the following query :

$usertherd = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] ");
$usertherdcoun = $usertherd[total];
$userpostdcoun = $post[posts] - $usertherdcoun ;
$userscann = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] AND forumid=37");
$userscann1 = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] AND forumid=20");
$userscann2 = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] AND forumid=12");
$userscanncoun = $userscann[total]+$userscann1[total]+$userscann2[total] ;

i put this in function.php below this lines:

$post[homepage]="";
$post[findposts]="";
$post[signature]="";
$onlinestatus="";
}

Now, the problem is that, when i delete a member without deleting his posts i have the following error message :

Database error in vBulletin 2.2.6:

Invalid SQL: SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=
mysql error: You have an error in your SQL syntax near '' at line 1

mysql error number: 1064

help me please

thanks

iggy123 03-22-2003 09:21 PM

yea I got that as well when it was an "unregistered" person posting.... Please help

amykhar 03-22-2003 10:12 PM

put an if clause around the query that makes sure userid is set.

Amy

Xenon 03-23-2003 04:20 PM

use this code:

PHP Code:

if (intval($post['userid']) > 0) {
$usertherd $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] ");
$usertherdcoun $usertherd[total];
$userpostdcoun $post[posts] - $usertherdcoun ;
$userscann $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE postuserid=$post[userid] AND forumid IN (12,20,37)"); 
$userscanncoun $userscann[total]+$userscann1[total]+$userscann2[total] ;


but you shouldn't use this as it produces a queries per post, which will increase the showthread load a lot..


All times are GMT. The time now is 12:37 AM.

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.00899 seconds
  • Memory Usage 1,720KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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