Opencart Fatal error: Call to a member function get() on a non-object

跟風遠走 提交于 2019-12-10 12:38:09

问题


Trying to move from local host to new server. Fresh install worked fine, no problems. When I uploaded my files mydomain.com/admin comes up with a white screen and mydomain.com produces this error:

Fatal error: Call to a member function get() on a non-object in /home4/pawpostc/public_html/index.php on line 103.

So I took a look at index.php line 103:

if ($config->get('config_error_display')) {
        echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on     line <b>' . $errline . '</b>';
    }

Seems like there is a problem with my config files. So I went and had a look at them. I have gone over them a few times but can not find the mistake, probably missing something, so here are the config files.

config.php (in my root www. folder):

<?php
// HTTP
define('HTTP_SERVER', 'http://www.pawpost.com.au/');
define('HTTP_IMAGE', 'http://www.pawpost.com.au/image/');
define('HTTP_ADMIN', 'http://www.pawpost.com.au/admin/');

// HTTPS
define('HTTPS_SERVER', 'http://www.pawpost.com.au/');
define('HTTPS_IMAGE', 'http://www.pawpost.com.au/image/');

// DIR
define('DIR_APPLICATION', '/home4/pawpostc/public_html/catalog/');
define('DIR_SYSTEM', '/home4/pawpostc/public_html/system/');
define('DIR_DATABASE', '/home4/pawpostc/public_html/system/database/');
define('DIR_LANGUAGE', '/home4/pawpostc/public_html/catalog/language/');   
define('DIR_TEMPLATE', '/home4/pawpostc/public_html/catalog/view/theme/');
define('DIR_CONFIG', '/home4/pawpostc/public_html/system/config/');
define('DIR_IMAGE', '/home4/pawpostc/public_html/image/');
define('DIR_CACHE', '/home4/pawpostc/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home4/pawpostc/public_html/download/');
define('DIR_LOGS', '/home4/pawpostc/public_html/system/logs/');

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'my user name');
define('DB_PASSWORD', 'my password');
define('DB_DATABASE', 'my database');
define('DB_PREFIX', 'oc_');
?>

admin/config.php:

<?php
// HTTP
define('HTTP_SERVER', 'http://www.pawpost.com.au/admin/'); 
define('HTTP_CATALOG', 'http://www.pawpost.com.au/');
define('HTTP_IMAGE', 'http://www.pawpost.com.au/image/');

// HTTPS
define('HTTPS_SERVER', 'http://www.pawpost.com.au/admin/');
define('HTTPS_CATALOG', 'http://www.pawpost.com.au/');
define('HTTPS_IMAGE', 'http://www.pawpost.com.au/image/');

// DIR
define('DIR_APPLICATION', '/home4/pawpostc/public_html/admin/');
define('DIR_SYSTEM', '/home4/pawpostc/public_html/system/');
define('DIR_DATABASE', '/home4/pawpostc/public_html/system/database/');
define('DIR_LANGUAGE', '/home4/pawpostc/public_html/admin/language/');
define('DIR_TEMPLATE', '/home4/pawpostc/public_html/admin/view/template/');
define('DIR_CONFIG', '/home4/pawpostc/public_html/system/config/');
define('DIR_IMAGE', '/home4/pawpostc/public_html/image/');
define('DIR_CACHE', '/home4/pawpostc/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home4/pawpostc/public_html/download/');
define('DIR_LOGS', '/home4/pawpostc/public_html/system/logs/');
define('DIR_CATALOG', '/home4/pawpostc/public_html/catalog/');

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'my user name');
define('DB_PASSWORD', 'my password');
define('DB_DATABASE', 'my database');
define('DB_PREFIX', 'oc_');
?>

Any help on this would be appreciated.


回答1:


I was using opencart and installed vqmod. All of a sudden I have one of the same errors.

This solved my problem: in system/library/session.php replace start session with:

session_save_path(realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../tmp'));



回答2:


The most likely issue is that one or more of your library files are corrupt from uploading. Re upload your system/library/ folder from your local one. Your config files seem fine and the error doesn't reference a config issue. What is line 103 in your index.php file?




回答3:


please cross check you have set all permissions i had came across this error and was solved, that was due to a file permission problem




回答4:


I was struggling with the same problem after migrating my site to a new VPS environment. I figured it HAD to be something to do with the changed document-root path or permissions of my shop and pulled out a lot of hair trying to get to the core of the problem.

I finally realised that I had incorrect permissions on my PHP session-data store! In my case, the folder at /var/lib/php/session/ was owned by apache (naturally) but I had changed apache to run as a different user so it could no longer write to the session-store.

The error messages in this case are cryptic (to say the least!) and didn't give a clue that the problem might just be lack of write permission!

Oh well, we should know by now that 90% of unix issues are down to perms!




回答5:


I upload a file at my server (directory: vqmod/....php ).

Just change vqmod file permission. I set 777 and that solved it.




回答6:


From the error you received, it looks like the $config variable is not getting set. The $config variable is set on line 35 using the Config class which is located in system/library/config.php

I think if you figure out why the class isn't getting instantiated, you'll be able to fix the issue. This could be a couple things:

  • The system/library/config.php file may not have been uploaded to the new server
  • As mentioned in previous answers, there could be a permissions issue. Check the permissions of system/library/config.php and make sure the correct user has ownership.
  • Or it could be a completely unrelated issue.



回答7:


The error is due to permissions set on the cache folder. Setting that to 755 and the files to 555 with set you home and dry.




回答8:


I had the same issue. I changed vqmod permission to 777. I am not sure this solved the problem, but I checked my website without adding www. before the domain and it worked. The warning was removed if I check http://daytodaystore.com. If I check http://www.daytodaystore.com, the warning is there.




回答9:


I had this problem when i migrated my server from 2G to 4GH on Godaddy. Came across this forum and found that the issue is with session.php Then, i guessed 'tmp' folder was missing. So, i created one just one step above html folder. and gave it a 777 access. Problem was fixed and my website looks great after that.



来源:https://stackoverflow.com/questions/12737880/opencart-fatal-error-call-to-a-member-function-get-on-a-non-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!