Fatal error: Call to a member function assistance required - php

I have taken over a website to complete.
The website works fine.
for some reason I get the following error:
Fatal error: Call to a member function navigate() on a non-object in C:\xampp\htdocs\studio.php on line 224
This is the code for the page at line 224:
if(!empty($_GET['nav']))
{
$params = null;
$params['listOrder'] = 'id desc';
$$_GET['nav']->navigate($params); <<<This is line 224
}
Any assistance will be greatly appreciated.

$$_GET['nav'] refers to an object dynamically, this object is not instanciated at the point of calling navigate(), or the variable passed to $_GET['nav'] does not correspond to a defined variable.

My problem has been resolved. after a strenuous search I found a phantom piece of code that was where it should not have been. Thank you all for your assistance. The code was:
$user = $_SESSION['usr'];

Related

Why $this->Html not defined but $this->html in cakephp?

I am using CakePHP 2.X latest. Facing unique error.
This is error i am getting:
Warning (2): call_user_func_array() expects parameter 1 to be a valid
callback, first array member is not a valid class name or object
[CORE/Cake/Utility/ObjectCollection.php, line 132]
Warning (2): call_user_func_array() expects parameter 1 to be a valid
callback, first array member is not a valid class name or object
[CORE/Cake/Utility/ObjectCollection.php, line 132]
Fatal error: Call to a member function link() on a non-object in
/data/html/savaganza/app/View/Elements/header.ctp on line 21
I am simply using Html in my header element
Line 21: <?php echo $this->Html->link('Categories', array('controller'=>'categories') ); ?>
This Header element is calling from all views this is giving me error for some view, i don't know why but its working fine for some views.
Efforts:
When i change $this->Html to $this->html it works why???
When i tried var_dump($this->Html) it gives string(58)
"�H��.
Its working in my loacal server but not in live server.
Suggest me please.
May be this question link to Weird PHP error: 'Can't use function return value in write context'
Perfect Answer: Because empty is not a function but a language construct (not sure), and it only takes variable
but when i change this line:
$des = (!empty(html_entity_decode($c['Coupon']['description'])))?html_entity_decode($c['Coupon']['description']):'Not Avaliable';
to
$des = html_entity_decode($c['Coupon']['description']);
$des = (!empty($des)) ? $des : 'Not Avaliable';
It works i don't know exact reason. Hope somebody help me to understand this.

Fatal Error: Call to member function xpath to non-object AFTER uploading to provider

I'm trying to extract data from a tumblr XML-Feed and it works perfectly on my local MAMP-Server. However, having uploaded it to my provider's server I get the following error:
Fatal error: Call to a member function xpath() on a non-object in
/home/httpd/vhosts/anthronaut.net/subdomains/nico/httpdocs/scripts/tumblr.php
on line 19
Here's the part of the code in question:
$request_url = "http://nicolasblandin.tumblr.com/api/read";
$xml = simplexml_load_file($request_url);
$posts = $xml->xpath("/tumblr/posts/post");
My hunch is that the serverside settings need to be changed. I found one setting allow_url_fopenand set it to true, however with no success.
Any ideas would be greatly appreciated! Thanks
The problem seems to be that simplexml_load_file returns an array of type SimpleXMLElement. So, changing the third line of your code to
$posts = $xml[0]->xpath("/tumblr/posts/post");
seems to solve the issue. The real question is now: why does it actually work in the other case?

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.

I am getting the error in my magento site

Fatal error:Call to member function getproduct() on a non-object in app/...../checkout/cart/sidebar/default.phtml on line 29
Why this happen?
Any solution to remove this error??
To remove error,
Go to app/design/frontend/your_theme/checkout/cart/sidebar/default.phtml
Search for getproduct
Comment its line and check.
It happens because, You called the function on an object not associated to it.
Have you used
$_product = Mage::getModel('catalog/product')->load($product_id)
before using it?

Non-object when adding code into html

I am getting the following error:
Fatal error: Call to a member function error() on a non-object in /home/gamepla3/public_html/football/result.php on line 177
The line for this is
<?php echo $form->error("homescore"); ?>
I'm failing to see how this could be the case?
The thing worked fine before I added working code into my html document so it looked better.
Now I can't get it working??
EDIT.
When the code is not within HTML, it works fine.
Once I have it within the HTML, it throws back an error?
Has anyone seen anything like this before?
var_dump($form);
Well, this just require a little & simple debug logic
Confirm $form is a Form object, try this
$class_methods = get_class_methods('form');
foreach ($class_methods as $method_name)
{
echo "$method_name\n";
}
does error is a defined method for Form object?
Based on your comment, the error is not a define method for object Form, so
$form->setError('homescore');
$errors = $form->getErrorArray();
// or $errors = $form->getError();

Categories