This Opencart tutorial collects most common errors that we face while development and provides solutions for errors, try them and hope you could solve the issues

1. Blank White Pages or 500 Internal Server Error

Blank white pages is a PHP error that for some reason the error messages don’t show because your server is not set up to display the errors.

  1. Go to the admin>> System >> Setting >> Edit store >> Server tab and at the end where you see the Error handling choose Yes to “Display Errors “.
  2. If you still don’t see the error, open php.ini and add code below: display_errors = 1; error_reporting = E_ALL; log_errors = 1;
  3. If you still don’t see the error then open index.php and add code below at the top (line 2): ini_set(‘display_errors’, 1); ini_set(‘log_errors’, 1); error_reporting(E_ALL);
  4. Still seeing the error then, set your “Output Compression Level” to 0 in the System > Settings > Server tab.
  5. If you still see the error, solve the issues but if you did not see the errors then most probably it will be Server error.
  6. You can see error logs at file also if you had enabled it.

With above mostly it gets solve and the 500 Internal Server Error can be solved with similar approach.

2. Undefined Index / Variable

An undefined variable in the source code of a computer program is a variable that is accessed in the code but has not been previously declared by that code. So for that use isset() to checks if the variable has been set will solve the issue.

Error variant:

Notice: Undefined index: filter in /Applications/XAMPP/xamppfiles/htdocs/opencart303/catalog/controller/product/category.php on lin

Solution
//$filter = $this->request->get['filter'];

if (isset($this->request->get['filter'])) {
    $filter = $this->request->get['filter'];
} else {
    $filter = '';
}
  • Commenting $filter = $this->request->get[‘filter’]; and checking with isset is one way to solve it.
  • If you get the issue while installing the modules or extensions then need to check the code or solve the issues or contacting the developer can be also another solution.

3. Undefined Function / Method

Undefined function/method errors are seen when you call those functions or methods are not defined and not found. IE_ERROR: A fatal error that causes script termination “Fatal error: Call to undefined function” or “Fatal error: Call to undefined method”. It happens if files are not found or the extensions are not compatible with your OpenCart version. Solutions can be below:

Error variant:

Related to OpenCart core files

  • Fatal error: Uncaught Error: Call to undefined method DB\MySQLi::query()
  • Fatal error: Uncaught Error: Call to undefined method Cart\Cart::getProducts() 
  • Fatal error: Uncaught Error: Call to undefined method ControllerAccountLogin::validate() in …/catalog/controller/account/login.php:54 

Go to the file and check whether the function or methods are defined there.

4. Headers Already Sent

Error variant:
  • Warning: Cannot modify header information – headers already sent by (output started at /public_html/config.php:31) in /path/public_html/index.php on line.
Solution:

Remove spaces at the beginning and end of the file mentioned. Like in the above error check with the config.php

5. Session Issue

  1. Product on the cart is self-cleared.
  2. Product on the cart is cleared after user logged in.
  3. No items stored at product compares.
  4. OpenCart admin always asking to login and get message “Invalid token session. Please login again”.
Error variant:
  • Warning: session_start () [function.session-start]: open (/tmp/…, O_RDWR) failed: No such file or directory (2) in /path/public_html/system /library /session.php on line
Solution:

No such file or directory issue

  1. Open php.ini and add code below:session.save_path = /tmp;
  2. If solution above not work, contact your host and ask them how to set session.save_path.

6. Allowed Memory Size Exhausted

This error happen because your memory is not enough to execute the php code (uploading large image, delete lot of products, send mass mails etc). Increasing the memory allocated for PHP will solve the issue.

Error variant:
  • Fatal error: Allowed memory size of 1111 bytes exhausted (tried to allocate 1111 bytes) in /path/public_html/system/library/image.php on line
Solution:
  1. Edit php.ini and set memory_limit = 128M;
  2. Or put code below to .htaccess php_value memory_limit 128M
  3. If above does not works then contacting the hosting providers is only the solution where they can increase the number.

Some other errors that you can face are below:

Error: Calls to magic methods are not allowed!

// Stop any magical methods being called
if (substr($this->method, 0, 2) == '__') {
return new \Exception('Error: Calls to magic methods are not allowed!');
}

Error: Could not call product/category

// Initialize the class
		if (is_file($file)) {
			include_once($file);
		
			$controller = new $class($registry);
		} else {
			return new \Exception('Error: Could not call ' . $this->route . '/' . $this->method . '!');
		}

Error: Could not load model

if (!$this->registry->has('model_' . str_replace('/', '_', $route))) {
    $file = DIR_APPLICATION . 'model/' . $route . '.php';
    $class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $route);

    if (is_file($file)) {
        include_once($file);
        $proxy = new Proxy();
	// Overriding models is a little harder so we have to use 
        //  PHP's magic methods
	// In future version we can use runkit
        foreach (get_class_methods($class) as $method) {
            $proxy->{$method} = $this->callback($this->registry, $route . '/' . $method);
        }

        $this->registry->set('model_' . str_replace('/', '_', (string)$route), $proxy);
    } else {
        throw new \Exception('Error: Could not load model ' . $route . '!');
    }
}

Error: Could not load library

Error: Could not load helper

Error: Could not load cache adaptor memcache/redis/apc cache!

$class = 'Cache\\' . $adaptor;
if (class_exists($class)) {
    $this->adaptor = new $class($expire);
} else {
    throw new \Exception('Error: Could not load cache adaptor ' . $adaptor . ' cache!');
}

Error: Could not load database adaptor mpdo/mssql/mysql/mysqli/postgre !

$class = 'DB\\' . $adaptor;
if (class_exists($class)) {
    $this->adaptor = new $class($hostname, $username, $password, $database, $port);
} else {
    throw new \Exception('Error: Could not load database adaptor ' . $adaptor . '!');
}

Error: Could not make a database connection using this username and password

Error: Could not connect to database opencart

Error: PHP GD is not installed!

if (!extension_loaded('gd')) {
    exit('Error: PHP GD is not installed!');
}

Error: Could not load image filename !

Error: Invalid session ID!

Warning: Install folder still exists and should be deleted for security reasons!

Fatal error uncaught exception

Fatal error: Uncaught Exception: Error: Table ‘….oc_session’ doesn’t exist in engine<br />Error No: 1932<br />SELECT `data` FROM `oc_session` WHERE session_id = ‘….’ AND expire > 1548638620 in …/system/library/db/mysqli.php:40 Stack trace: #0 …/system/library/db.php(45): DB\MySQLi->query(‘SELECT `data` F…’) #1 

For these errors to solve create database table will solve most of the issues

Fatal error: Uncaught Exception: Error: Could not load database adaptor DB_DRIVER!

Check in system/library/db folder whether the required driver file is there.

Hope you solve the problems, if you find and then please let us know, then we try to provide the solutions.

opencart error, opencart blank white page, opencart headers already sent, opencart undefined index, opencart undefined variable, opencart restriction in effect, opencart memory size exhausted, opencart undefined method, opencart undefined function, opencart invalid token session, opencart internal server error, vqmod, opencart out of memory,error,issue,troubleshoots,tutorials

LEAVE A REPLY

Please enter your comment!
Please enter your name here