vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Total views on non-vb page (Query included) (https://vborg.vbsupport.ru/showthread.php?t=41512)

Logician 07-25-2002 05:05 PM

mysql_result should be used once for a variable. Then the assigned var becomes an ordinary variable and you can use it WITHOUT mysql_result.. So you used

PHP Code:

$numberguest=mysql_result($loggedins,0); 

in your code and assign the result to "$numberguest" var which is now an ORDINARY variable. From now on whenever when you want to use $numberguest use it as it is (ie. without mysql_result!)

So replace line echo mysql_result($numberguest,0); to

echo $numberguest;

BTW you else syntax is wrong either: it should be:

PHP Code:

if (mysql_error()) {echo "mySQL error:"; echo mysql_error(); exit;}                                                //show error if any
else
{
echo 
$totalonline ;
echo 
$numbervisible ;
echo 
$numberguest;


Seems you are tired, give it a rest.. ;)

wooolF[RM] 07-25-2002 05:08 PM

I think MAYBE it's because of $cookietimeout variable... it's not defined any places... what do you think?

wooolF[RM] 07-25-2002 05:16 PM

]well... maybe I'm tired :) maybe... but I have to get it working... :)

by now I have no errors anymore! YAY!

but visual results are:

Active Users 0
Active Members
Active Guests 0

And forum tells me this:
Active Users 46
Active Members 24
Active Guests 22


So... maybe you are tired too :)
Because Active Users and Active Guests working only at 50% (show wrong results) and Active Members doesn't show anything at all...

:( grrrrrrrrrrrr... why should everything be so difficult? :/

Logician 07-25-2002 05:37 PM

PHP Code:

mysql_connect("$servername""$dbusername""$dbpassword") or die("Couldnt find MYSQL!");
mysql_select_db("$dbname")  or die ("Couldnt find DB!");


// STARTING QUERIES HERE
$aktiveuser mysql_query("SELECT COUNT(userid) FROM user");
$registers mysql_query("SELECT userid, username FROM user ORDER BY userid DESC LIMIT 1");
$datecutmktime (date("H"), date("i")-15date("s"), date("m"), date("d"), date("Y"));
$loggedins=mysql_query("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity > $datecut");
$numberguest=mysql_result($loggedins,0);
$loggedins=mysql_query("SELECT DISTINCT session.userid,username,invisible,usergroupid
                              FROM session
                              LEFT JOIN user ON (user.userid=session.userid)
                              WHERE session.userid>0 AND session.lastactivity>
$datecut
                              ORDER BY invisible ASC, username ASC"
);
while (
$loggedin=mysql_fetch_row($loggedins)) {
    
$numberregistered++;
    if (
$loggedin[2]==0) {$numbervisible++;}
}
$totalonline=$numberregistered+$numberguest;
$numberinvisible=$numberregistered-$numbervisible;
// END OF QUERIES HERE

echo 'totalonline='.(int)$totalonline; echo("<br><br>");
echo 
'numbervisible='.(int)$numbervisible; echo("<br><br>");
echo 
'guests='.(int)$numberguest; echo("<br><br>"); 


wooolF[RM] 07-25-2002 07:20 PM

]you're the man, Logician! :) worked perfectly...

as you see, it's not easy to get it working... u have to use different ways... well... that's PHP...

anyway, THANX A LOT!!! I really appreciate your help :)


All times are GMT. The time now is 07:02 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.01238 seconds
  • Memory Usage 1,743KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete