vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Server Time Out ? (https://vborg.vbsupport.ru/showthread.php?t=50464)

fla5h 03-19-2003 03:09 PM

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 ?

Dpcows 03-19-2003 03:20 PM

Your stuck in a loop

Xenon 03-19-2003 03:33 PM

if it's jsut a littel script, can you please post it, maybe there's just a littl bug in it

fla5h 03-19-2003 06:07 PM

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

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 :D

fla5h 03-19-2003 06:17 PM

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 ?

fla5h 03-19-2003 06:36 PM

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 ?

Xenon 03-19-2003 06:40 PM

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

Xenon 03-19-2003 06:42 PM

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

fla5h 03-19-2003 07:06 PM

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 ?

Xenon 03-19-2003 09:24 PM

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.


All times are GMT. The time now is 03:20 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.02140 seconds
  • Memory Usage 1,772KB
  • 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
  • (3)bbcode_php_printable
  • (2)bbcode_quote_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
  • (10)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