PDA

View Full Version : php include what am i doing wrong


recklessop
02-22-2008, 02:30 AM
ok so i read http://www.vbulletin.com/docs/html/templates_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:

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.