Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Error: Call to a member function on a non-object
Old 10-01-2009, 05:22 AM Error: Call to a member function on a non-object
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I have the strangest error, and I can't seem to solve it. I have tracked down the error to this function call

$image->getImageID()

where $image is an instance of a class 'Image'. However, I get the error

Fatal error: Call to a member function getImageID() on a non-object in /Applications/MAMP/htdocs/kittens.php on line 51

To debug, I did this:
PHP Code:
echo '<pre>' print_r($imagetrue) . '</pre>'
and I get a correct output of the whole object, telling me that it is indeed an Image object.

Code:
Image Object
(
    [imageID:protected] => 138
    [mimeType:protected] => image/png
    [name:protected] => 2n4wSPCG2jeqrsE4ljD8Q7mu1y0ENm
    [uploaded:protected] => 2009-09-30 15:36:57
    [width:private] => 515
    [height:private] => 489
    [fields:protected] => Array
        (
            [imageID] => 
            [mimeType] => 1
            [name] => 1
            [uploaded] => 
        )

    [id:protected] => imageID
)
If I change that row to

PHP Code:
echo '<pre>' print_r($image->getImageID(), true) . '</pre>'
(or any other function which this class have) I get the same error again.

Any ideas?
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 10-01-2009, 06:04 AM Re: Error: Call to a member function on a non-object
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Ok, the $image is an object.
But does this object has a method name getImageId() defined in it ?
Or is it declared as static ?

Take care of the case, as getImageID() is not the same as getImegeId() for PHP.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 10-01-2009, 07:33 AM Re: Error: Call to a member function on a non-object
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Finally, I found the error. I have an array with these Image objects which goes through a loop. Apparently one of the array elements was null, due to some error elsewere. So php's error messages make sense after all, as usual.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Error: Call to a member function on a non-object
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61328 seconds with 12 queries