"Trying to get property of non-object" in PHP include
Posted: 01 September 2008 12:28 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 01 September 2008 10:50 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 01 September 2008 11:12 AM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  2064
Joined  05-07-2007

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

 Signature 
Profile
MSG
 
 
Posted: 01 September 2008 11:19 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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?

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 01 September 2008 11:52 AM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

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

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 01 September 2008 12:19 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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…?)

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 01 September 2008 12:27 PM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12433
Joined  04-29-2002

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?

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 01 September 2008 01:08 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 01 September 2008 01:35 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 02 September 2008 01:14 PM   [ Ignore ]   [ # 9 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32921
Joined  05-14-2004

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.

 Signature 
Profile
MSG
 
 
Posted: 02 September 2008 04:39 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 02 September 2008 05:02 PM   [ Ignore ]   [ # 11 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32921
Joined  05-14-2004

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? =)

 Signature 
Profile
MSG
 
 
Posted: 16 September 2008 09:42 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  423
Joined  12-15-2005

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

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 17 September 2008 05:01 AM   [ Ignore ]   [ # 13 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12433
Joined  04-29-2002

Moved per your request.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65085 Total Logged-in Users: 38
Total Topics: 82223 Total Anonymous Users: 19
Total Replies: 441915 Total Guests: 219
Total Posts: 524138    
Members ( View Memberlist )
Newest Members:  BombermanhaimtuagocsadamVeNeaDoRHildegaardhrtrulzUNFORGIVEN IIIEmmanuelYanYanTomsB