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 03-19-2003, 03:09 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Server Time Out ?

Hello,
I have written a small stats script for displaying members details.

The problem is that it doesn't show all the members, it seems to cut off after about the first 50. Is there anything that would make the script stop / timeout ?

Looking at the stats its taking about 3.5 seconds to display the page and 8 queries.

Any clues ?
Reply With Quote
  #2  
Old 03-19-2003, 03:20 PM
Dpcows Dpcows is offline
 
Join Date: Feb 2002
Location: Netherlands
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your stuck in a loop
Reply With Quote
  #3  
Old 03-19-2003, 03:33 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if it's jsut a littel script, can you please post it, maybe there's just a littl bug in it
Reply With Quote
  #4  
Old 03-19-2003, 06:07 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sure thanks for the help, I cannot see a loop to be stuck in, but I know nothing compared to you

PHP Code:
<?php

require('./global.php');

$r1=$DB_site->query("SELECT user.userid, user.username, user.joindate, user.posts, user.lastactivity, 

post.dateline, 

post.threadid,
usergroup.title, thread.title as ptitle
FROM user,post,usergroup,thread
WHERE user.lastpost=post.dateline AND user.usergroupid=usergroup.usergroupid AND 

post.threadid=thread.threadid
ORDER BY usergroup.title,user.username"
);



    while(
$bob=mysql_fetch_array($r1))
{


    
$q2=$DB_site->query_first("select count(*) as postuserid from thread where 

postuserid=
$bob[userid]");
    
$threads=$q2[postuserid];
    
$ld=$bob[dateline];
    
$ld2=date("d/m/y (G:i)",$ld);
    
$lv=$bob[lastactivity];
    
$lv2=date("d/m/y (G:i)",$lv);
    
$jd=$bob[joindate];
    
$jd2=date("d/m/y (G:i)",$jd);

    eval(
"\$memberdeets .= \"".gettemplate("memberdeets")."\";");    



}

eval(
"dooutput(\"".gettemplate("memberdeetspage")."\");");

?>
This will show the following stats

Username
Usertitle ( not custom title )
Posts
Threads
Last Post ( both Date / Time and thread id )
Last visit Date / Time
Joined Date / Time

I am going to add a few more, but before I do I cannot understand why it stops at 50 odd members.

Would it help if I adopted the VB style where the number of results a page is used ?

Ie only 30 per page ?

Thanks for any help given
Reply With Quote
  #5  
Old 03-19-2003, 06:17 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

mmm, looking at this code, its erm how can I say crap. just looked at the stats for it.

Mmmm, can anyone give me a lesson in optimising ?

How would I remove the queries inside the loop so they are not called everytime ?

Could this be why its stopping short of all the members because I'm loading the server too much ?
Reply With Quote
  #6  
Old 03-19-2003, 06:36 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

mmm am I a little out of my depth here ??

The script above gives stats of

Quote:
Page generated in 15.43927801 seconds (1.93% PHP - 98.07% MySQL) with 78 queries.
However if I alter the script slightly,

PHP Code:
<?php

require('./global.php');


$q1="SELECT user.userid, user.username, user.joindate, user.posts, user.lastactivity, post.dateline, post.threadid,
usergroup.title, thread.title as ptitle
FROM user,post,usergroup,thread
WHERE user.lastpost=post.dateline AND user.usergroupid=usergroup.usergroupid AND post.threadid=thread.threadid
ORDER BY usergroup.title,user.username"
;
$r1=mysql_query($q1);


    while(
$bob=mysql_fetch_array($r1))
{

    
$q2="select count(*) from thread where postuserid=$bob[userid]";
    
$r2=mysql_query($q2);
    
$ld=$bob[dateline];
    
$ld2=date("d/m/y (G:i)",$ld);
    
$lv=$bob[lastactivity];
    
$lv2=date("d/m/y (G:i)",$lv);
    
$jd=$bob[joindate];
    
$jd2=date("d/m/y (G:i)",$jd);


    while(
$bill=mysql_fetch_array($r2))  {
   eval(
"\$memberdeets .= \"".gettemplate("memberdeets")."\";");  

}}
eval(
"dooutput(\"".gettemplate("memberdeetspage")."\");");



?>
The stats show as

Quote:
Page generated in 3.41518295 seconds (97.98% PHP - 2.02% MySQL) with 8 queries.
I still only get the first 50 odd member results, but I guess the second query is better ? Less queries more php ?

Am I correct here ?
Reply With Quote
  #7  
Old 03-19-2003, 06:40 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

indeed that could be the problem, but we'll find a way



PHP Code:
<?php

require('./global.php');

$r1=$DB_site->query("SELECT user.userid, user.username, user.joindate, user.posts, user.lastactivity, 

post.dateline, 

post.threadid,
usergroup.title, thread.title as ptitle
FROM user,post,usergroup,thread
WHERE user.lastpost=post.dateline AND user.usergroupid=usergroup.usergroupid AND 

post.threadid=thread.threadid
ORDER BY usergroup.title,user.username"
);

$threadstarters=$DB_site->query("SELECT COUNT(*) AS count, postuserid FROM thread GROUP BY postuserid");
while(
$threadstarter=$DB_site->fetch_array($threadstarters)) {
 
$threadcount[$threadstarter['postuserid']] = $threadstarter['count'];
}

    while(
$bob=$DB_site->fetch_array($r1))
{


    
$threads=$threadcount[$bob['userid']];
    
$ld=$bob[dateline];
    
$ld2=date("d/m/y (G:i)",$ld);
    
$lv=$bob[lastactivity];
    
$lv2=date("d/m/y (G:i)",$lv);
    
$jd=$bob[joindate];
    
$jd2=date("d/m/y (G:i)",$jd);

    eval(
"\$memberdeets .= \"".gettemplate("memberdeets")."\";");    



}

eval(
"dooutput(\"".gettemplate("memberdeetspage")."\");");

?>

a restriction to 30 users per page isn't needed, but wouldn't hurt
Reply With Quote
  #8  
Old 03-19-2003, 06:42 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

for your last post before mine:

ohm, the microstats doesn't work if you use mysql_query.

the truth is the second is as bad as the first one, just the querycount is wrong because you didn't use $DB_site->query
Reply With Quote
  #9  
Old 03-19-2003, 07:06 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

are I see thats why the qury count is so low.

thank you for your script, its giving stats of

Page generated in 1.84838998 seconds (5.93% PHP - 94.07% MySQL) with 10 queries.

which is an improvement on mine, and now I get 69 members displayed, still not my total ammount of members ?

Sorry to be a pain.

Should I scrap this and try to modify the code found in user.php in the admin folder ?
Reply With Quote
  #10  
Old 03-19-2003, 09:24 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well what doy wou want to get exactly?

this part
Code:
FROM user,post,usergroup,thread
WHERE user.lastpost=post.dateline AND user.usergroupid=usergroup.usergroupid AND 

post.threadid=thread.threadid
is very suspicious and will take a long time, poor DB

if you tell exactly what ya want i can maybe optimize that code also

aslo as a tip for future:
lear to use significant variable names.
i don't know what $bob should mean, but $usersinthread would be clear.
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 07:47 PM.


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.04520 seconds
  • Memory Usage 2,284KB
  • 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
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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_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