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 09-16-2002, 06:58 PM
FlyingDutchman's Avatar
FlyingDutchman FlyingDutchman is offline
 
Join Date: Nov 2001
Location: The Netherlands
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL query problem.

i have some problems
i have this script:

PHP Code:
$threadz $DB_site->query("SELECT title,originalforumid,threadid FROM thread WHERE forumid='5'");

    if (!
$DB_site->num_rows($threadz)) {
          print 
'<br>No threads found.</b>';
    } else {
          while (
$thread_info $DB_site->fetch_array($threadz)) {
          
extract($thread_info);
          
$forumd $DB_Site->query("SELECT title FROM forum WHERE forumid='$thread_info[originalforumid]'");
          print 
'<br><b>'.$thread_info[title].'</b> - <a href="../postings.php?action=restore&threadid='.$thread_info[threadid].'&s='.$session[sessionhash].'">[restore]</a>'.$thread_info[originalforumid].'';
          }
    } 
it's working o.k, except for 1 line:

PHP Code:
$forumd $DB_Site->query("SELECT title FROM forum WHERE forumid='$thread_info[originalforumid]'"); 
it just keeps on giving me this error:

Code:
Fatal error: Call to a member function on a non-object in c:\file-x.php on line 31
I've already asked Xenon for help, but he doesn't know what the problem is either...
Thanks for any help you can give me,


FlyingDutchman



P.S. originalforumid is from type smallint(5) unsigned if that possibly matters (guess not, but ok)
Reply With Quote
  #2  
Old 09-16-2002, 07:01 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try adding before that line:

PHP Code:
global $DB_site 
Reply With Quote
  #3  
Old 09-17-2002, 03:25 AM
FlyingDutchman's Avatar
FlyingDutchman FlyingDutchman is offline
 
Join Date: Nov 2001
Location: The Netherlands
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've tried already... didn't work?!?!?
Reply With Quote
  #4  
Old 09-17-2002, 05:23 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you insure that global.php is being included in the file file-x.php?

Chances are the non-member object it's referring to is $DB_site.

If it is included at the top of the file, then try this instead:

Replace:
PHP Code:
$forumd $DB_Site->query("SELECT title FROM forum WHERE forumid='$thread_info[originalforumid]'"); 
With:
PHP Code:
$forumd $DB_Site->query_first("SELECT title FROM forum WHERE forumid='$thread_info[originalforumid]'"); 
And I'm just curious by the way, but what is the point of this query:
PHP Code:
$forumd $DB_Site->query("SELECT title FROM forum WHERE forumid='$thread_info[originalforumid]'"); 
It's usually never good to put a query inside a while loop, as it will generate many many queries..
Reply With Quote
  #5  
Old 09-17-2002, 12:31 PM
FlyingDutchman's Avatar
FlyingDutchman FlyingDutchman is offline
 
Join Date: Nov 2001
Location: The Netherlands
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it's for my (upcoming) recycle bin hack, it will get a listing of all threads that are in the recycle bin and it will also show the original forum title (which -the id- is saved in the row 'originalforumid' in the table 'thread'

this piece of code is for the admin CP...
i can't really move it out of the while loop, b/c the forumid variable ($thread_info[originalforumid]) is defined in the while loop...

of course i've required global.php and i've changed query to query_first also, but no luck


P.S. This code isn't really really needed for the hack, but i'd like to get it running this way, and just printing the forumid is kinda lame i think, the title suits better...
Reply With Quote
  #6  
Old 09-17-2002, 01:11 PM
FlyingDutchman's Avatar
FlyingDutchman FlyingDutchman is offline
 
Join Date: Nov 2001
Location: The Netherlands
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

w00t, I guess all you guys are as stupid as me

the fix is: change $DB_Site to $DB_site, d0h
i'm happy that i found out this typo myself
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 09:43 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.07246 seconds
  • Memory Usage 2,222KB
  • 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
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete