vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with query (https://vborg.vbsupport.ru/showthread.php?t=72806)

ericgtr 12-12-2004 05:55 PM

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)."');

tubedogg 12-12-2004 06:00 PM

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).");

ericgtr 12-12-2004 06:10 PM

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.

tubedogg 12-12-2004 06:13 PM

Can you post the surrounding code? i.e. two lines above through about five lines below.

ericgtr 12-12-2004 06:17 PM

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);

?>


ericgtr 12-13-2004 09:47 PM

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

tubedogg 12-14-2004 12:06 AM

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...


All times are GMT. The time now is 12:35 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.01905 seconds
  • Memory Usage 1,732KB
  • 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
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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