vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   howto display a user's post count(errors inside?) (https://vborg.vbsupport.ru/showthread.php?t=133537)

KingPin6 12-08-2006 10:40 PM

howto display a user's post count(errors inside?)
 
I wanted to display user post count and rep in a php file, I added total forum post count and total forum usercount and that worked out perfectly, when i add the user post count by supplying a userID it doesn't seem to work...

here is some sample code, sorry for the messy code, I'm trying to learn as I go :)

PHP Code:

$username=$_REQUEST['u'];
define('CWD', (($getcwd getcwd()) ? $getcwd '.'));
define('THIS_SCRIPT''something');

require_once(
CWD '/includes/init.php');
    
$totalthreads $db->query_first("SELECT COUNT(threadid) FROM " TABLE_PREFIX "thread");
$totalthreads implode(",",$totalthreads);
    
$totalposts $db->query_first("SELECT COUNT(postid) FROM " TABLE_PREFIX "post");
$totalposts implode(",",$totalposts);
    
$totalusers $db->query_first("SELECT COUNT(userid) FROM " TABLE_PREFIX "user");
$totalusers implode(",",$totalusers);
    
$userpost $db->query_first("SELECT posts FROM " TABLE_PREFIX "user WHERE username = '%s'",
    
mysql_real_escape_string($username));
$userpost implode(",",$userpost);
    
$userrep $db->query_first("SELECT reputation FROM " TABLE_PREFIX "user WHERE username = '%s'",
    
mysql_real_escape_string($username));
$userrep implode(",",$userrep); 

this one gives no result but no error either.

I also tryed :

PHP Code:

require_once(CWD '/includes/init.php');
    
$totalthreads $db->query_first("SELECT COUNT(threadid) FROM vb_thread");
$totalthreads implode(",",$totalthreads);
    
$totalposts $db->query_first("SELECT COUNT(postid) FROM vb_post");
$totalposts implode(",",$totalposts);
    
$totalusers $db->query_first("SELECT COUNT(userid) FROM vb_user");
$totalusers implode(",",$totalusers);
    
$userpost $db->query_first("SELECT posts FROM vb_user WHERE username = " $username);
$userpost implode(",",$userpost);
    
$userrep $db->query_first("SELECT reputation FROM vb_user WHERE username = " $username );
$userrep implode(",",$userrep); 

this one gives me :
Code:

Invalid SQL:
SELECT posts FROM vb_user WHERE username = KingPin;

MySQL Error  : Unknown column 'KingPin' in 'where clause'
Error Number : 1054

( I know I hardcoded the table prefix but I was just removing and changing things to get it to work...)

Any help appreciated.

Edit got it :

PHP Code:

$userpost $db->query_first("SELECT posts FROM " TABLE_PREFIX "user WHERE username = '$username'"); 

works like a charm.


All times are GMT. The time now is 12:38 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.01023 seconds
  • Memory Usage 1,735KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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