Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2005, 09:19 AM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Query to get number of post for a user today?

I need help with a query please...

I haven't been able to get anything to work with the plug in system, but I have seen similar hacks that use a similar idea.

The query needs to pull the number of posts a user has so far today for display in the posbit. (Not the past 24 hours, just in the current day).

How can I do this? Thanks.

~007

Here's the code that worked on 3.0: (rolling 24 hours, however, but this doesn't work either on 3.5)

PHP Code:
$cutoff=time()-86400
$postcount=$DB_site->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='$userid' AND dateline >= $cutoff"); 
I am trying to put it in postbit_start.

It comes up with "Call to a member function on a non-object" and I'm guessing it's because syntax has changed in 3.5... but I haven't the slightest clue where to begin. Any ideas?
Reply With Quote
  #2  
Old 09-16-2005, 05:27 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, the syntaxis error i can see is that you're using $DB_site-> and as far as i know that's from vb 3.0.x

so the proper command should be

$vbulletin->db->query_frist, so, making the whole sentence be:

PHP Code:
$cutoff=time()-86400
$postcount=$vbulletin->db->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='$userid' AND dateline >= $cutoff"); 
Reply With Quote
  #3  
Old 09-16-2005, 06:27 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, but I get the following with that:

Fatal error: Call to a member function on a non-object in ...../includes/class_postbit.php(251) : eval()'d code on line 2

What should I do?
Reply With Quote
  #4  
Old 09-16-2005, 06:29 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:

$db->query_first
Reply With Quote
  #5  
Old 09-16-2005, 06:32 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey, I get the same error with that.. Hmmm..
Reply With Quote
  #6  
Old 09-16-2005, 06:35 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

0k, now try this:

PHP Code:
$cutoff=time()-86400
$postcount=$vbulletin->db->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='".vbulletin->userinfo[$userid]."' AND dateline >= $cutoff"); 
if that one doesnt do the trick, try this one:

PHP Code:
$cutoff=time()-86400
$postcount=$vbulletin->db->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='".vbulletin->userinfo['$userid']."' AND dateline >= $cutoff"); 
Reply With Quote
  #7  
Old 09-16-2005, 06:37 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Getting closer..

I get this:

Parse error: parse error in ..../includes/class_postbit.php(251) : eval()'d code on line 2
Reply With Quote
  #8  
Old 09-16-2005, 06:42 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

none of em worked, hmmmm =/ what else can be the error, well, i think this one of this 2 should work:

PHP Code:
 $cutoff=time()-86400
$postcount=$vbulletin->db->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='".vbulletin->userinfo[$userid]."' AND dateline >=".$cutoff.""); 
or
PHP Code:
 $cutoff=time()-86400
$postcount=$vbulletin->db->query_first("SELECT COUNT(*) AS total FROM post WHERE userid='".vbulletin->userinfo['$userid']."' AND dateline >=".$cutoff.""); 
Reply With Quote
  #9  
Old 09-16-2005, 06:49 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bad news...

No go. Thanks for helping though. The COUNT (*) isn't the problem is it?
Reply With Quote
  #10  
Old 09-16-2005, 06:54 PM
White_Snake's Avatar
White_Snake White_Snake is offline
 
Join Date: Jul 2005
Location: Guadalajara Mexico
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmmm, well, try the query frist via phpmyadmin without variables or vbulletin commands, something like:
[SQL]
"SELECT COUNT(*) AS total FROM post WHERE userid='1' AND dateline >= 86400 ");
[/SQL]

if it doesnt work, well, maybe you have an sql syntaxis error, that's the only way to know if you're right
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:43 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.04573 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete