vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   help fix this error... (https://vborg.vbsupport.ru/showthread.php?t=53007)

squawell 05-16-2003 10:31 AM

help fix this error...
 
first im not know much about code so maybe the code have a little strange....

ok here we go...

i want to show the top poster in last week in my main page so i use this code in index.php

PHP Code:

$dmktime (0,0,0,date("m"),date("d")-7,date("Y"));
$post7day $DB_site->query_first("SELECT DISTINCT(userid),COUNT(postid) AS posts FROM post WHERE userid > 0 AND post.dateline>=$d GROUP BY userid ORDER BY posts DESC LIMIT 1");
while (
$xxx=mysql_fetch_array($post7day)){
$post7dayuser=$DB_site->query_first("SELECT username FROM user WHERE userid=$xxx[userid]");}
eval(
"\$topthread = \"".gettemplate("top_thread")."\";"); 

and i creat a template name:top_thread(contant with username and posts) also put the $topthread
in forumhome.....when i goto my main page i found the error message in my header...

Code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/squawell/public_html/XXX/forum/index.php on line 61
this is line 61
while ($xxx=mysql_fetch_array($post7day)){

want help....thankz......

Xenon 05-16-2003 10:36 AM

$DB_site->query_first never returns a mysql result, it returns a normal php array.

remove the _first to get it working..

edit: just the query before the while loop is meant ;)

squawell 05-16-2003 10:59 AM

Quote:

Today at 07:36 PM Xenon said this in Post #2
$DB_site->query_first never returns a mysql result, it returns a normal php array.

remove the _first to get it working..

edit: just the query before the while loop is meant ;)

thankz Xenon u always give me big help ...now the error is gone.....:D:D:D

but it only show up usernamethe post number did not below is the template in top_thread

PHP Code:

<a href=member.php?s=$session[sessionhash]&action=getinfo&userid=$xxx[userid]>$post7dayuser[username]</a><BR>$post7dayuser[posts

do i use wrong variable??thankz agian.....

Xenon 05-16-2003 11:08 AM

$post7dayuser=$DB_site->query_first("SELECT username FROM user WHERE userid=$xxx[userid]");}

you jhust read out username, not posts here ;)

squawell 05-16-2003 11:42 AM

Quote:

Today at 08:08 PM Xenon said this in Post #4
$post7dayuser=$DB_site->query_first("SELECT username FROM user WHERE userid=$xxx[userid]");}

you jhust read out username, not posts here ;)

oh.....how should i change my code to show them both???

Xenon 05-16-2003 09:47 PM

PHP Code:

$d mktime (0,0,0,date("m"),date("d")-7,date("Y"));
$post7day $DB_site->query_first("
  SELECT DISTINCT(post.userid), COUNT(postid) AS posts, user.username 
  FROM post 
  LEFT JOIN user USING(userid)
  WHERE post.userid > 0 AND post.dateline>=
$d 
  GROUP BY post.userid 
  ORDER BY posts DESC 
  LIMIT 1
"
);
eval(
"\$topthread = \"".gettemplate("top_thread")."\";"); 

template:
Code:

<a href=member.php?s=$session[sessionhash]&action=getinfo&userid=$xxx[userid]>$post7day[username]</a><BR>$post7day[posts]

squawell 05-17-2003 01:42 AM

Quote:

Today at 06:47 AM Xenon said this in Post #6
PHP Code:

$d mktime (0,0,0,date("m"),date("d")-7,date("Y"));
$post7day $DB_site->query_first("
  SELECT DISTINCT(post.userid), COUNT(postid) AS posts, user.username 
  FROM post 
  LEFT JOIN user USING(userid)
  WHERE post.userid > 0 AND post.dateline>=
$d 
  GROUP BY post.userid 
  ORDER BY posts DESC 
  LIMIT 1
"
);
eval(
"\$topthread = \"".gettemplate("top_thread")."\";"); 

template:
Code:

<a href=member.php?s=$session[sessionhash]&action=getinfo&userid=$xxx[userid]>$post7day[username]</a><BR>$post7day[posts]

thankz Xenon...it works!!!

another question...if i want another code also use in same template should i put the code above this

eval("\$topthread = \"".gettemplate("top_thread")."\";");

am i right?

Boofo 05-17-2003 02:44 AM

Xenon, how would you do this on a per forum type basis?

Xenon 05-17-2003 10:08 AM

@squawell: yes right, every variabole appearing in the template has to be before that eval!

@boofo:

it would slow down the query but i think this should do the trick:

PHP Code:

$post7day $DB_site->query_first("
  SELECT DISTINCT(post.userid), COUNT(postid) AS posts, user.username 
  FROM post 
  LEFT JOIN user USING(userid)
  LEFT JOIN thread USING(threadid)
  WHERE post.userid > 0 AND post.dateline>=
$d AND thread.forumid=xx
  GROUP BY post.userid 
  ORDER BY posts DESC 
  LIMIT 1
"
); 


squawell 05-17-2003 10:50 AM

Quote:

Today at 07:08 PM Xenon said this in Post #9
@squawell: yes right, every variabole appearing in the template has to be before that eval!

Thankz reply..Xenon :) :)

above ur code it will affect when u apply the code right?and the

post number will recount after 7 days later is that right too?? :)


All times are GMT. The time now is 01:38 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.01128 seconds
  • Memory Usage 1,764KB
  • 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_code_printable
  • (5)bbcode_php_printable
  • (4)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