Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 08-06-2008, 02:22 PM
nvitremi nvitremi is offline
 
Join Date: Aug 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default query_first_slave() error when trying to use vBulletin API outside of vBulletin

Hi,

Since the past two days, the only thing I'm trying to do with vBulletin is to display a login form or a user information box (when the user is logged in) on every pages of the site, including those not in vBulletin. That's it -- nothing fancy. I do not need or want full integration capabilities -- just display a user information box or a login box whether the user is logged in or not.

I followed a tutorial I found on this site and tried to make a page outside of vBulletin's directory and still use vBulletin's API. Even though I followed the instructions to the letter, I can't make a page outside vBulletin. I get the following error message:

Quote:
Call to a member function query_first_slave() on a non-object in /var/nvisionit/projects/precisionnutrition/www-newcms/forum/includes/functions.php on line 1303
Is there anything I can do to make this thing work once and for all?

Any help will be appreciated. Thanks in advance!
Reply With Quote
  #2  
Old 08-06-2008, 02:46 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should post the code so people can see it.
Reply With Quote
  #3  
Old 08-06-2008, 03:01 PM
nvitremi nvitremi is offline
 
Join Date: Aug 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here it is:

Code:
<?php
// https://vborg.vbsupport.ru/showthread.php?t=98009

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT', 'test');

// #################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array(
        // change the lines below to the list of actual templates used in the script
        'pn_test',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################
$forumdir = $pnsite->getConfig('forumdir');
chdir($forumdir);
require_once('./global.php');
// I checked the "forumdir" above and the path is correct
// since the file "global.php" gets loaded.

// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

$navbits = array(); 
// change the line below to contain whatever you want to show in the navbar (title of your custom page)
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
print_output($navbar);

// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('pn_test') . '");');
I also cleared all my cookies for the site, thus I'm no longer logged in. I get different errors in this case:

Quote:
Warning: array_keys() [function.array-keys]: The first argument should be an array in [path]/includes/functions.php on line 4088

Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 4088

( ! ) Fatal error: Call to a member function query_read_slave() on a non-object in /var/nvisionit/projects/precisionnutrition/www-newcms/forum/includes/functions.php on line 3093
Reply With Quote
  #4  
Old 08-06-2008, 03:22 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What are you spitting out though? I see you eval your template pn_test, but nothing is there to go into pn_test - perhaps post that template. Also, I hope you have a closing php tag at the end ("?>")? And, I don't think you need the line "print_output($navbar);"
Reply With Quote
  #5  
Old 08-06-2008, 03:58 PM
nvitremi nvitremi is offline
 
Join Date: Aug 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I usually don't put closing tags when I only have PHP code in my file. See "Instruction separation" in PHP documentation.

Execution errs at "global.php". Anything after that is not executed.

--------------- Added [DATE]1218043772[/DATE] at [TIME]1218043772[/TIME] ---------------

I forgot to mention the custom template "pn_test" simply contains "TEST".
Reply With Quote
  #6  
Old 08-06-2008, 04:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does it work if you do the following:
PHP Code:
// ########################## REQUIRE BACK-END ############################

chdir(/path/to/the/vbulltin/forums);
require_once(
'./global.php'); 
Reply With Quote
  #7  
Old 08-06-2008, 04:43 PM
nvitremi nvitremi is offline
 
Join Date: Aug 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No. Still the same happens -- no different.
Reply With Quote
  #8  
Old 08-06-2008, 06:45 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What version of VB are you running ?
Reply With Quote
  #9  
Old 08-06-2008, 06:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Um, I just noticed something.... you didn't really create a template that only has the word "TEST" in it, did you? It needs to be html compliant. ie:
HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
    <td class="tcat" colspan="2">Title</td>
</tr>
<tr>
    <td class="alt1" colspan="2">Text</td>
</tr>
</table>

$footer
</body>
</html>
Also, as I said, be sure to remove the print_output line.
Reply With Quote
  #10  
Old 08-07-2008, 08:10 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really don't see how the following can work:
PHP Code:
// ########################## REQUIRE BACK-END ############################
$forumdir $pnsite->getConfig('forumdir');
chdir($forumdir);
require_once(
'./global.php'); 
$pnsite is not even defined at this point.
Reply With Quote
Reply

Thread Tools
Display Modes

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 03:15 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.10611 seconds
  • Memory Usage 2,259KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_postinfo_query
  • fetch_postinfo
  • 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