vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   php include what am i doing wrong (https://vborg.vbsupport.ru/showthread.php?t=171149)

recklessop 02-22-2008 02:30 AM

php include what am i doing wrong
 
ok so i read http://www.vbulletin.com/docs/html/t..._externalfiles

and i followed it and this is my plugin

ob_start();
include('banners/showbanner.php');
$justinbanner = ob_get_contents();
ob_end_clean();


however im getting errors such as

Fatal error: Call to a member function query_read_slave() on a non-object in /home/beta/public_html/index.php on line 394

any ideas?

thanks

calorie 02-22-2008 06:33 AM

One idea would be to look at the showbanner.php file and see if $db->query_read_slave or $vbulletin->db->query_read_slave appears within a function. If so, globalize $db or $vbulletin near the beginning of the function:
Code:

global $db;
global $vbulletin;

Another idea is to look at the code from the /home/beta/public_html/index.php file, around line 394 to see what it is doing. Seems like a scope issue, i.e., a variable needs to be globalized, but without more info, it's a guess.

recklessop 02-23-2008 01:13 AM

i figured it out... i had no idea that you couldnt do normal php mysql syntax... didnt know i had to use $db->query and what not.. after i converted the page to the vb syntax all worked fine

Dismounted 02-23-2008 10:53 AM

It's called OOP (Object Orientated Programming). vBulletin's structure utilises the available OOP features in PHP 4. I suggest you have a read of what it's about.


All times are GMT. The time now is 08:28 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.00978 seconds
  • Memory Usage 1,713KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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