Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
help fix this error... Details »»
help fix this error...
Version: , by squawell squawell is offline
Developer Last Online: May 2008 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 05-16-2003 Last Update: Never Installs: 0
 
No support by the author.

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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 05-17-2003, 11:16 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
above ur code it will affect when u apply the code right?
huh? what do you mean?

no the postnumber won't recount every 7 days, it will always be dynamical for the last seven days, so every day you'll see another value
Reply With Quote
  #13  
Old 05-17-2003, 11:58 AM
squawell's Avatar
squawell squawell is offline
 
Join Date: Oct 2001
Posts: 681
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 08:16 PM Xenon said this in Post #11
huh? what do you mean?

no the postnumber won't recount every 7 days, it will always be dynamical for the last seven days, so every day you'll see another value
i mean i use ur code it will affect when i apply it right...

so it cant count last 7 days the most posts user and change the stats every 7days later.....
Reply With Quote
  #14  
Old 05-17-2003, 12:52 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes the code will work right.

nope every new day the value will be recalculated.
it will not have weekly stats but stats the last 7 days
Reply With Quote
  #15  
Old 05-20-2003, 03:33 PM
squawell's Avatar
squawell squawell is offline
 
Join Date: Oct 2001
Posts: 681
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
05-17-03 at 09:52 PM Xenon said this in Post #13
yes the code will work right.

nope every new day the value will be recalculated.
it will not have weekly stats but stats the last 7 days
so Xenon the variable mean last 7 days

$d = mktime (0,0,0,date("m"),date("d")-7,date("Y"));

if i want last 30 days should i change like this

$d = mktime (0,0,0,date("m"),date("d")-30,date("Y"));

is that right?
Reply With Quote
  #16  
Old 05-20-2003, 06:16 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

exactly
Reply With Quote
  #17  
Old 05-21-2003, 01:01 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
05-17-03 at 06:08 AM Xenon said this in Post #9
@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
"
); 
I tried this code and this is the error I got.

Database error in vBulletin 2.2.9:

Invalid SQL: 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>=1052895600 AND thread.forumid=34
GROUP BY post.userid
ORDER BY posts DESC
LIMIT 1

mysql error: Unknown column 'user.threadid' in 'on clause'

mysql error number: 1054

Date: Wednesday 21st of May 2003 06:31:41 AM
Script: http://www.bearfacts2.com/forum/foru...php?forumid=34
Referer: http://www.bearfacts2.com/forum/
Repair Report: This type of error cannot be automatically repaired.
Reply With Quote
  #18  
Old 05-21-2003, 01:04 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm than that way:

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 ON(post.threadid=thread.threadid)
  WHERE post.userid > 0 AND post.dateline>=
$d AND thread.forumid=xx
  GROUP BY post.userid 
  ORDER BY posts DESC 
  LIMIT 1
"
); 
Reply With Quote
  #19  
Old 05-21-2003, 01:58 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That ran without any errors but it wouldn't show the stats.
Reply With Quote
  #20  
Old 05-21-2003, 03:25 PM
squawell's Avatar
squawell squawell is offline
 
Join Date: Oct 2001
Posts: 681
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Yesterday at 10:58 PM Boofo said this in Post #18
That ran without any errors but it wouldn't show the stats.
that code i use in index.php not forumdisplay.php......

and it works.....................
Reply With Quote
  #21  
Old 05-21-2003, 03:30 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

But it also should work in the forumdisplay.
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 10:59 AM.


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.04431 seconds
  • Memory Usage 2,315KB
  • Queries Executed 25 (?)
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)bbcode_code
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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