We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

"Trying to get property of non-object" in PHP include

Development and Programming

DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

My brain hurts. I’ve been battling this for over a day now and am no closer to a solution. I know it’s not policy to review/debug third-party scripts, but I could use some illumination as it appears to be EE’s handling of the include in question that is problematic.

The code I’m using is the Vogoo LIB, available here. It comprises a core include, plus a couple of supplementar ones depending on the required functionality.

The template code is:

<?
error_reporting(E_ALL);
include($_SERVER['DOCUMENT_ROOT']."/vogoo/vogoo.php");
include($_SERVER['DOCUMENT_ROOT']."/vogoo/items.php");

$vogoo_check = $vogoo->connected;

if($vogoo_check)
    {
    echo "heya";
    $ret = $vogoo_items->member_get_recommended_items(1);
    print_r($ret);
    } else {
    generate_error(0,"Vogoo DB not connecting");
    }
?>

Which produces the following errors:

Notice: Trying to get property of non-object in /home/dir/public_html/vogoo/items.php on line 90

Fatal error: Call to a member function sql_query() on a non-object in /home/dir/public_html/vogoo/items.php on line 90

I’ve seen some talk on the boards here about variables and scope setting, but frankly am unsure where to start. I’ve confirmed this is working properly just in native PHP docs on the server, so it is something to do with how EE is resolving…. something.

Moved to Modules: Technical Assistance by Moderator

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

14 views but no posts, so wondering if the question is poorly constructed?

       
Greg Aker's avatar
Greg Aker
6,022 posts
16 years ago
Greg Aker's avatar Greg Aker

DEA:

It looks like the db class isn’t being called correctly. Look through vogoo.php and see where it calls the db class. You might want to hard code the links instead of the way they have it. I’m not sure if that’s going to do the trick, but it’s worth a try.

-greg

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Thanks Greg. I have in fact tried hardcoding all path statements and it has no effect at all. I’m convinced it has something to do with how globals are set, but it’s beyond my skillset to properly determine unfortunately.

Edit: have also noticed the PHP script in question is setting a $db var for accessing its database functions. Could this conflict with EE’s own DB class?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

I don’t know if this helps at all but I once had a problem with a PHP script running from inside ExpressionEngine as an include and found out in the end that the variables inside the included PHP file needed to all be set to global variables or else I had all sorts of problems. It was above me how to do this but the developers of the script did this for me and then it worked fine. Not sure if that is what is happening in your case though.

Best wishes,

Mark

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Heya Mark, Yep that sounds like it could be the culprit here for sure. And like you, it’s above my pay grade :p Hoping either someone here could help, and also pursuing it with the script author (I did pay for both EE and the script so that should get me SOMEwhere, right…?)

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

DEA, this topic is beyond the scope of technical support.. but as Greg mentioned, it may have to do with how the DB is being declared.

Are the tables in question found within EE’s database? If so, you could use EE’s database routines.

Is the script author familiar with EE?

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Hi Sue, The db function is invoked in the script as $db. Could this conflict with EE’s own class?

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Bummed. I’ve just realized I’ve hit the point where hacking EE is taking as much time as it has saved me from having to do other things. Keep looking at CodeIgniter and Wordpress and others, but have been daunted at the thought of rebuilding from scratch. Cry. :down:

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
16 years ago
Lisa Wess's avatar Lisa Wess

DEA - I think that, in this case, since you’re dealing with what looks like a rather complex script, you’d have a much easier time building that into a module so that you can address any conflicts in the module code.

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

I know, was afraid you’d say that! 😛 I wonder if it’s easier to integrate into CI instead?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
16 years ago
Lisa Wess's avatar Lisa Wess

I honestly do not know. In either case, this one is something that needs to be addressed in another method - did you want me to move this to How To for you? Or Modules, perhaps? =)

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Doh! Missed your response. Sure thing, if you think it could help, maybe into Modules? Thanks!

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Moved per your request.

       
colddigital's avatar
colddigital
12 posts
15 years ago
colddigital's avatar colddigital

I just started playing with Vogoo in EE and ran into this exact issue today.

DEA, did you have any luck building a Vogoo module, or come across any other fixes?

thanks,

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.