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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2004, 05:55 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with query

I setup a $newmembers variable and I want it to display how many users have registered in the last 24 hours but I keep getting errors. Here is the code I am trying to use, any help would be great.

$newmembers=$DB_site->query_first("SELECT COUNT(*) AS count FROM user WHERE joindate>'".(time()-3600*24)."');
Reply With Quote
  #2  
Old 12-12-2004, 06:00 PM
tubedogg's Avatar
tubedogg tubedogg is offline
 
Join Date: Oct 2001
Location: Medina, OH
Posts: 785
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's the error you are getting?

Two notes just off the top...you should be taking into account the TABLE_PREFIX, like shown below, and you don't need single quotes around an integer such as the joindate, so the query would look like:
$newmembers = $DB_site->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."user WHERE joindate > ".(time()-3600*24).");
Reply With Quote
  #3  
Old 12-12-2004, 06:10 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tubedogg
What's the error you are getting?

Two notes just off the top...you should be taking into account the TABLE_PREFIX, like shown below, and you don't need single quotes around an integer such as the joindate, so the query would look like:
$newmembers = $DB_site->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."user WHERE joindate > ".(time()-3600*24).");
I tried what you gave me and I still get an error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/vhfansco/public_html/vb/modules/stats.php on line 32

What it's doing is giving me this parse error 2 lines past the line of code that I am adding for some reason.

I should also mention this is for my stats module on my vbadvanced, still I set it up like all the others.
Reply With Quote
  #4  
Old 12-12-2004, 06:13 PM
tubedogg's Avatar
tubedogg tubedogg is offline
 
Join Date: Oct 2001
Location: Medina, OH
Posts: 785
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you post the surrounding code? i.e. two lines above through about five lines below.
Reply With Quote
  #5  
Old 12-12-2004, 06:17 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, here's the entire module it's not too big. Hopefully it's okay to post this here, I will use the code tag.

Code:
<?php
// ++=========================================================================++
// || vBadvanced CMPS v1.0.0
// || ? 2003-2004 vBadvanced.com & PlurPlanet, LLC - All Rights Reserved
// || This file may not be redistributed in whole or significant part.
// || http://vbadvanced.com
// || Downloaded 08:52, Wed Nov 17th 2004
// || 
// ++ ========================================================================++

// ######################### Forum Stats #########################
include_once('./includes/functions_forumlist.php');
cache_ordered_forums(1, 0, 0);
if (is_array($forumcache))
{
	foreach ($forumcache AS $forum)
	{
		$nthreads += $forum['threadcount'];
		$nposts += $forum['replycount'];
		$totalthreads = number_format($nthreads);
		$totalposts = number_format($nposts);
	}
}

$topposter = $DB_site->query_first('SELECT username, posts, userid FROM ' . TABLE_PREFIX . 'user ORDER BY posts DESC LIMIT 1');
$userstats = unserialize($datastore['userstats']);
$numbermembers = number_format($userstats['numbermembers']);
$newusername = $userstats['newusername'];
$newuserid = $userstats['newuserid'];
//$newmembers = $DB_site->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."user WHERE joindate > ".(time()-3600*24).");
$tdate = vbdate('Y-m-d', TIMENOW);
$birthdaystore = unserialize($datastore['birthdaycache']);
if (!is_array($birthdaystore) OR ($tdate != $birthdaystore['day1'] AND $tdate != $birthdaystore['day2']))
{
	include_once('./includes/functions_databuild.php');
	$birthdaystore = build_birthdays();
}
switch($tdate)
{
	case $birthdaystore['day1']:
		$birthdays = $birthdaystore['users1'];
		break;

	case $birthdaystore['day2'];
		$birthdays = $birthdaystore['users2'];
		break;
}
$birthdays = str_replace(array('member.php', ','), array($vboptions['bburl'] . '/member.php', '<br />'), $birthdays);

eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_stats') . '";');

unset($userstats, $birthdays, $birthdaystore, $topposter);

?>
Reply With Quote
  #6  
Old 12-13-2004, 09:47 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i got this worked out, the info is here if anyone is interested. I hate it when i dig for something and find a question and the reply is "nevermind I figured it out" when I need the answer lol. http://www.vbadvanced.com/forum/showthread.php?t=3988
Reply With Quote
  #7  
Old 12-14-2004, 12:06 AM
tubedogg's Avatar
tubedogg tubedogg is offline
 
Join Date: Oct 2001
Location: Medina, OH
Posts: 785
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ericgtr
i got this worked out, the info is here if anyone is interested. I hate it when i dig for something and find a question and the reply is "nevermind I figured it out" when I need the answer lol. http://www.vbadvanced.com/forum/showthread.php?t=3988
Just noticed the problem...the last
."
shouldn't be there...oops...
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 11:22 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03878 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete