vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   SQL query problem. (https://vborg.vbsupport.ru/showthread.php?t=43629)

FlyingDutchman 09-16-2002 06:58 PM

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)

NTLDR 09-16-2002 07:01 PM

Try adding before that line:

PHP Code:

global $DB_site 


FlyingDutchman 09-17-2002 03:25 AM

i've tried already... didn't work?!?!?

Velocd 09-17-2002 05:23 AM

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

FlyingDutchman 09-17-2002 12:31 PM

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

FlyingDutchman 09-17-2002 01:11 PM

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

the fix is: change $DB_Site to $DB_site, d0h ;)
i'm happy that i found out this typo myself :)


All times are GMT. The time now is 07:08 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.01045 seconds
  • Memory Usage 1,735KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete