Trying to get property of a non-object - php

I thought I had resolved this error when I added the if block below, but I'm still erroring out. This line of code is causing the following errror:
Fatal PHP error on line 95 of /XXXXX/GetContactValuesOsVc.php:
Trying to get property of non-object
Line 95 is the if condition here:
if($contact->CustomFields->c->ask_again->LookupName){
$Contactname=$contact->CustomFields->c->ask_again->LookupName;
}
Anyone know why merely checking for existence (what that line should be doing I think) would be causing the error im getting?

Related

Can't figure out what is causing this Fatal error: Call to a member function format() on a non-object in

The php file that I have has been starting to act up lately. It has been working for years up until just a month ago. I have looked everywhere and can not find anything that will fix this issue.
In the screenshot its the line that is circled that is throwing the error of
Fatal Error: Call to a member function format() on non-object in .....php.
So if I change it
$recent_hire_date = date_format($employee['STRTDATE'],'Ymd');
I then later have to move down further in the PHP file and update each one that is like the one in circled line. However, when I run this php file (it generates a file), When looking at the data in the file it actually only shows 0 it does not show the correct data.

Notice: Trying to get property of non-object in /home/../feednew.php on line 161

$item[$value['field_name']] = stripwhitespace(nv_convert(strip_tags($element->find($el[0],$el[1])->innertext)));
Throws back this error:
Notice: Trying to get property of non-object in /home/../feednew.php on line 161** >> >innertext
This part of your code: $element->find($el[0], $el[1]) does not return any object. You have to find out why. Maybe, your search parameters $el[0] and $el[1] are wrong, maybe the function itself is incomplete. We can't get more information from this line of code.

setFormFieldName() on a non-object magento Admin

On manage product page, I'm getting no grid, I traced it and it shows the error
Fatal error: Call to a member function setFormFieldName() on a non-object in /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php on line 279
I don't know whats wrong with it.
I think the FieldName value is invalid, it should be $this->getMassactionBlock()->setFormFieldName('product_id');

PHP fatal error: Call to a member function asXML() on a non-object

I'm attempting to run a php script to parse Google Calendar XML and I keep getting the following error:
Call to a member function asXML() on a non-object in /index.php on line 120
Here's a link to my code (I've notated Line 120 - IT IS LINE 38 ON PASTEBIN) http://pastebin.com/bMHXfbkD
Anybody with any ideas / fixes would be much appreciated!
UPDATE #Clover and #Phil have suggested I remove the line in question, which I did, and got this:
Notice: Trying to get property of non-object in /Library/WebServer/Documents/index2.php on line 125
Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/index2.php on line 125
simplexml_load_file function can return FALSE, so make a test before using it.
By the way, in your case, just remove the line, it does nothing :)
use try catch, and instead of using Exception class, try Throwable class

Fatal error: Call to a member function in product.php

I am new to opencart, so please help me.
I am using opencart version 1.5.6, now whenever I edit and delete the product it shows me
Fatal error: Call to a member function productUpdateListen() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 78
and
Fatal error: Call to a member function deleteProduct() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 133 respectively.
Although it edit and delete the product.
Please help me how to fix it.
Code in Line 78 $this->openbay->productUpdateListen($this->request->get['product_id'], $this->request->post);
And code in line 133 $this->openbay->deleteProduct($product_id);
This means $this->openbay is not an object which contains function productUpdateListen() & deleteProduct(), probably it's NULL or false in some cases (nothing found) due to it's not accessible. Out of scope.
Try
var_dump($this->openbay);
Check the O/P
it's simple and the error-message says it all: your $this->openbay doesn't have those methods (productUpdateListen() and deleteProduct()) - most likely it isn't an object at all.
please debug your code since it's impossible to say what's going wrong wich so little information. to start, do a var_dump($this->openbay); right before the function-calls and check the output.

Categories