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 02-19-2005, 06:41 PM
Deaths Deaths is offline
 
Join Date: Oct 2004
Location: Europe, Belgium
Posts: 679
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What's wrong with this query?

Whats wrong with this query?

[sql]SELECT * FROM thread WHERE forum.forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]

I get this error:

Code:
Database error in vBulletin 3.0.6:

Invalid SQL: 
		SELECT * FROM thread WHERE forum.forumid = 13 ORDER BY ID DESC LIMIT 10
	
mysql error: Unknown table 'forum' in where clause

mysql error number: 1109
Reply With Quote
  #2  
Old 02-19-2005, 06:43 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[sql]
SELECT * FROM " . TABLE_PREFIX . "thread WHERE " . TABLE_PREFIX . "forum.forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]
Reply With Quote
  #3  
Old 02-19-2005, 06:49 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lol it is not the only prefix Zach He refers to the forum table in the where clause, but forum is not used in the FROM clause. Typical copy&paste&edit error.

[sql]SELECT * FROM " . TABLE_PREFIX . "thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]
Reply With Quote
  #4  
Old 02-19-2005, 07:02 PM
Deaths Deaths is offline
 
Join Date: Oct 2004
Location: Europe, Belgium
Posts: 679
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks .
I don't have time to try this out, but it looks promising.\

Quote:
Typical copy&paste&edit error.
Yep, so many idea's, so little time... If only I had time to handle every idea with the same time and care...
Reply With Quote
  #5  
Old 02-19-2005, 10:30 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Deaths
Thanks .
I don't have time to try this out, but it looks promising.\


Yep, so many idea's, so little time... If only I had time to handle every idea with the same time and care...
I was getting the thing i knew was wrong one at a time ay ?
Reply With Quote
  #6  
Old 02-20-2005, 06:47 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ay ay
Reply With Quote
  #7  
Old 02-20-2005, 07:34 AM
Deaths Deaths is offline
 
Join Date: Oct 2004
Location: Europe, Belgium
Posts: 679
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ya goo' ol' pirate!

Still didn't work .

Query:
PHP Code:

$getnewposts 
$DB_site->query_first("SELECT * FROM " TABLE_PREFIX "thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10"); 
Error:
Code:
Invalid SQL: SELECT * FROM thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10
mysql error: Unknown column 'ID' in 'order clause'

mysql error number: 1054
Reply With Quote
  #8  
Old 02-20-2005, 08:13 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm ORDER BY threadid or forumid maybe?

Dont know what order you want.
Reply With Quote
  #9  
Old 02-20-2005, 08:47 AM
Akex Akex is offline
 
Join Date: Jul 2003
Location: France
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would say "ORDER BY dateline desc"

But if you want the last posts prefer this one

PHP Code:
$getnewposts $DB_site->query("SELECT p.* FROM " TABLE_PREFIX "post as p
LEFT JOIN " 
TABLE_PREFIX "thread as t ON (t.threadid = p.threadid)
WHERE t.forumid = 13 ORDER BY p.dateline DESC LIMIT 10"
); 
Reply With Quote
  #10  
Old 02-20-2005, 08:54 AM
Deaths Deaths is offline
 
Join Date: Oct 2004
Location: Europe, Belgium
Posts: 679
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, now the DB error is gone.

But, with this code:

PHP Code:
$getnewposts $DB_site->query_first("SELECT * FROM " TABLE_PREFIX "thread WHERE forumid = 13 ORDER BY dateline desc LIMIT 10 
"
); 
$newposts number_format($getnewposts['count']); 
It just returns a "0", even though I'm absolutely sure there's a new post in the forum 13...
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 02:57 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.04084 seconds
  • Memory Usage 2,260KB
  • 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
  • (2)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