There is nothing more excited then try to build your own ecommerce store. Installing OpenCart extensions and themes, modificate them to your need and learn new thing during development. But most OpenCart users know how frustrating it can be get an unexpected error and not be able to find a solution for it.
Most OpenCart issues are solvable. If you got an error, don’t fret because other OpenCart user had the same problem and already gotten it solved. This tutorial collecting most common errors that repeatedly asked by OpenCart users at community forum. Sometime the same error have different error messages, that why we organize the error variant and solution for it.
Before continue, you need to know that an error usually trigger another errors. This is commonly happen because when your code breaks, the rest of code will not work and cause another error. No need to be confuse, the first error is the key. Recognise the error, find issue in your code and try to solve them with solution as suggested on this tutorial.
1. Blank White Pages or 500 Internal Server Error
Blank white pages is a PHP errors that for some reason the error messages isn’t show because your server is not setup to display the errors. While the 500 Internal Server Error means something has gone wrong but the server cannot specifically state what the exact problem is.
The similiarity of both issue is it doesn’t give us a clue what exactly happen, or what files triggering the errors. So, first step before we try to solve the errors is try to show the error messages. Then use the error message as starting point to investigate what is the error cause. Here are a few ways to show the error messages:
1. Set your “Output Compression Level” to 0 in the System > Settings > Server tab.
2. Then open php.ini and add code below:
display_errors = 1;
error_reporting = E_ALL;
log_errors = 1;
3. If your server not read the php.ini, we will use an alternative method. Open index.php and add code below at the top (line 2):
4. When you have fixed the problem, remove code line above.
2. Undefined Index / Variable
The error appears when you referencing variable that not been declared. In programming approach set the variable or use isset() to checks if the variable has been set will solve the issue. But for an application to get this issue mean there is a bugs in it, whether it’s OpenCart or extensions files. Or you do some modification on unappropriate way.
- PHP Notice: Undefined index: company in /path/public_html/catalog/model/account/customer.php on line 8
- PHP Notice: Undefined variable: order_id in /path/public_html/catalog/controller/account/order.php on line 149
- PHP Notice: Undefined variable: product in /path/public_html/vqmod/vqcache/vq2-catalog_view_theme_default_template_product_product.tpl on line 272
- If you get this issue on clean OpenCart installation, share the bugs at OpenCart forum. It will help OpenCart developer to develope bugs fix.
- When you get this issue after installing an extension, disable the extension then report it to the developer.
- If the error refer to file inside the “/vqmod/vqcache” folder, it’s mean the error caused by vQmod file. Disable the vQmod file by rename it to vqmod_file.xml_ and report the bugs to the developer.
3. Undefined Function / Method
If you get “Fatal error: Call to undefined function” or “Fatal error: Call to undefined method” means you try to call the function/ method that doesn’t exist. Commonly happen if files is not uploaded properly or the extensions is not compatible with your OpenCart version; or it’s really doesn’t exist. Here, I will try to classify the problem based on error message.
Related to OpenCart core files
- Fatal error: Call to undefined function utf8_strlen() in /path/public_html/system/helper/utf8.php on line 39
- Fatal error: Call to undefined method Customer::isLogged() in /path/public_html/catalog/model/catalog/product.php on line 8
- Warning: require_once(/path/public_html/system/library/customer.php) [function.require-once]: failed to open stream: No such file or directory in /path/public_html/index.php on line 22
- Fatal error: require_once() [function.require]: Failed opening required‘/path/public_html/system/library/customer.php’ (include_path=’.:/usr/lib/php’) in /path/public_html/index.php on line 22
Related to vQmod files
- Fatal error: Call to undefined method ModelAccountCustomer::getPaymentAddress() in /path/public_html/vqmod/vqcache/vq2-catalog_controller_checkout_confirm.php on line 38
Related to PHP built-in functions
- Fatal error: Call to undefined function imagecreatefromjpeg() in /path/public_html/system/library/image.php on line 34
- Fatal error: Call to undefined function mysql_connect() in /path/public_html/system/database/mysql.php on line 6
Related to OpenCart core files
- Some file is not uploaded or it’s corrupted during upload process. Reupload the files to your server with ASCII mode, not binary.
- In some case, this issue appear because server path is not configured properly at config.php. So recheck your server path in config.php and admin/cofig.php
- “Warning/ Fatal error: require_once” mean the file is not available. You need to reupload the file mentioned on the error message or fix the server path at config.php as mentioned above.
Related to vQmod files
- vQmod fails to generate new cache from the extensions vQmod files. Check vqmod/cachefolder permission, make sure it’s writable and clear all cache files.
- Enabled / disabled one by one vQmod files you have. Once you get the cause, contact the developer.
- The extensions is not compatible with your OpenCart version or it have a bug. Contact the developer.
Related to PHP built-in functions
- PHP have lot of built-in functions, you can check it here. Errors related to PHP built-in function is server issues. Contact your host to solve this.
4. Headers Already Sent
You get an error message “headers already sent” right after installing, modificating, updating OpenCart or vQmod files. There is a good refference explaining the issue.
- Warning: Cannot modify header information – headers already sent by (output started at /path/public_html/config.php:31) in /path/public_html/index.php on line 175.
- Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /path/public_html/config.php:31) in /path/public_html/system/library/session.php on line 11.
- Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /path/public_html/config.php:31) in /path/public_html/system/library/session.php on line 11.
Download the file stated at the error message then apply solution bellow:
- Remove spaces at begining and end of file.
"remove all space or line-break before <?php and after ?>"
- Resave the file with Notepad++ or other editor (encode file as ANSI or UTF-8 without BOM).
- Reupload to server through FTP in ASCII mode, not binary.
5. Session Issue
PHP session store user information on the server for later use (i.e. login status, shopping items, etc) across the page requests. Session is temporary information and will be deleted after the user left the website. OpenCart use session on lot of aspect like login status, product cart, compare etc. In most case, session issue will throw error messages. But there is time when it’s not show any error message; to recognise it, here is some indication of session issue:
- Product on the cart is self-cleared.
- Product on the cart is cleared after user logged in.
- No items stored at product compares.
- OpenCart admin always asking to login and get message “Invalid token session. Please login again”.
- Warning: session_start () [function.session-start]: open (/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: No such file or directory (2) in /path/public_html/system /library /session.php on line 11
- Warning: session_start () [function.session-start]: open (/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: Permission denied (13) in /path/public_html/system /library /session.php on line 11
- Warning: session_start() [function.session-start]: open(/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: No space left on device (28)in /path/public_html/upload/system/library/session.php on line 11
No such file or directory issue
- Open php.ini and add code below:
session.save_path = /tmp;
- If solution above not work, contact your host and ask them how to set session.save_path.
- “Permission denied”, ask your hosting to check the session directory permission.
- “No space left on device”, ask your hosting is it server issue or you need to upgrade to larger hosting space.
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.
- Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 47200 bytes) in /path/public_html/system/library/image.php on line 34
- Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13069817 bytes) in /path/public_html/system/library/mail.php on line 144
- Fatal error: Out of memory (allocated 33554432) (tried to allocate 14024 bytes) in /path/public_html/library/image.php on line 34
Apply one of solutions bellow to increasing the limit to 64MB, 128MB, 256MB or 512MB -depends on your host.
- Edit php.ini
- Or put code below to .htaccess
php_value memory_limit 128M
- If you oftenly get this error and solution above isn’t work, contact your host. In most shared hosting, there is maximum memory_limit. You can’t set memory-limit to 64Mb if you get max 32Mb.
7. Restriction in effect
You get an error message “SAFE MODE Restriction in effect”. This is a PHP restriction issue, and your server account is trying to run a -builtin PHP- functions but doesn’t have access to run it. This issue is nothing to do with OpenCart, but related to your server configuration.
- Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 10025 is not allowed to access /path/public_html/system/library/session.php on line 11
- Warning: imagejpeg() [function.imagejpeg]: SAFE MODE Restriction in effect. The script whose uid is 10305 is not allowed to access /path/public_html/image/cache/data owned by uid 48 in /path/public_html/system/library/image.php on line 44
- Warning: is_dir(): open_basedir restriction in effect. File(/path/public_html/image/87cngmlc22pe96fof5fhmq9c290phri7) is not within the allowed path(s): (/path/server/) in /path/public_html/catalog/controller/checkout/confirm.php on line 248
- Safe Mode and open_basedir restriction is a server issue, ask your host to turn off the restriction is the best way to fix the issue.
- But in case you wanna try to resolve it, try this solution:
// Put code bellow at php.ini
safe_mode = Off;
// Put code bellow at .htaccess
php_value safe_mode off
System Information provide server information, PHP built-in functions and file/ folder permission that required or recomended by OpenCart. This extension will help you to monitor that your site / server meet OpenCart requirements to work well. You can download it at OpenCart Marketplace.
vQmod Manager allows users to managing vQmod files. This extension display vQmod file information and help you to manage (Upload, delete, install, uninstall and backup) and monitor the vQmod files through the admin panel. You can download
it at OpenCart Marketplace.