Categories

有特色的模板

OpenCart. 常见错误及解决方法

Mary Gilmore March 31, 2015
Rating: 4.3/5. From 4 votes.
Please wait...

This tutorial shows how to solve the common OpenCart errors.

Issue 1. 空白页或500内部服务器错误

Blank white page is a PHP error which is just not visible when the server is not configured 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.

  1. Log into your Opencart admin.

  2. Go to 系统-设置-“编辑” and set ‘Output Compression Level’ to 0:

    Common OpenCart errors and ways to solve themimages1

  3. Open php.ini and add 下面的代码:

    Display_errors = 1;
    error_reporting = E_ALL;
    log_errors = 1;

    Common OpenCart errors and ways to solve themimages2

  4. If php.ini is not used or read by the server, you can use an 替代的方法 – open index.php file and add the following code to the top of the file (line 2):

    报错(' display_errors ', 1);
    报错(' log_errors ', 1);
    error_reporting (E_ALL);

    Common OpenCart errors and ways to solve themimages3

    问题一解决,请尽快通知我 remove the above code.

Error 2. 未定义索引/变量

The error appears when you are referencing the variable that has not been declared in PHP.

Error variants:

PHP Notice:未定义索引:/path/public_中的公司html/目录/模型/账户/客户.php on line 8.

PHP Notice:未定义变量:/path/public_ .目录下的order_idhtml/目录/控制器/账户/订单.php on line 149.

PHP Notice:未定义变量:product 在/道路/ public_html/vqmod/vqcache/vq2-catalog_view_theme_default_template_product_product.tpl on line 272.

Solutions:

  1. If you get this issue after installing a third party extension, disable the extension.

  2. 如果错误指的是文件中的 ‘/vqmod/vqcache’ 文件夹,则表示错误是由 vQmod file. Rename the vQmod file to vqmod_file.xml_.

Issue 3. 未定义函数/方法

If you get Fatal error:调用undefined function or ‘Fatal error:调用undefined method’, it means you try to call the function/方法不存在. The error commonly happens if the files are 上传不正常 or the extensions are not compatible with your OpenCart version.

Error variants:

  1. 与OpenCart核心文件相关:

    Fatal error:调用undefined function Utf8_strlen () 在/道路/ public_html/系统/帮助/ utf8.php on line 39;

    Fatal error:调用undefined method Customer::isLogged() 在/道路/ public_html/目录/模型/目录/产品.php on line 8;

    Warning: require_once(/道路/ public_html/系统/图书馆/客户.php) [function.require-once]: failed to open stream: No such file or directory 在/道路/ public_html/index.PHP在第22行;

    Fatal error: require_once() [function.require]: Failed opening required ‘/path/public_html/系统/图书馆/客户.php”(include_path = '.:/usr/lib/php ')在/path/public_html/index.PHP在第22行;

  2. Related to vQmod files:

    Fatal error:调用undefined method ModelAccountCustomer::getPaymentAddress() 在/道路/ public_html/vqmod/ vqcache vq2-catalog_controller_checkout_confirm.PHP在第38行;

  3. 与PHP内置函数相关:

    Fatal error:调用undefined function Imagecreatefromjpeg()在/path/public_html/系统/图书馆/形象.php on line 34

    Fatal error:调用undefined function mysql_connect()在/path/public_html/system/database/mysql.php on line 6

Solutions:

  1. 与OpenCart核心文件相关:

    -有些文件 上传不正常 or corrupted 在上传过程中. Re-upload 将文件发送到服务器 ASCII mode, not binary:

    Common OpenCart errors and ways to solve themimages4

    – “Warning/ Fatal error: require_once”表示 文件不可用. You need to 重新上传文件 在错误消息中提到或修复 server path for config.php (确保配置.PHP文件位于admin/config目录下.php).

  2. Related to vQmod files:

    vQmod 无法生成新的 cachevQmod files. Check vqmod/cache 文件夹权限,确保他们是 writable and clear all cache files.

    启用/禁用 vQmod files 一个接一个.

    – The extensions are not compatible with the OpenCart version you use.

  3. 与PHP内置函数相关:

    —与PHP内置函数相关的错误如下 server issues. 与你的朋友取得联系 hosting 提供商解决此类问题.

Issue 4. 已发送的报头

The error message “headers already sent” commonly occurs right after installing, modifying, 更新OpenCart或 vQmod files.

Error variants:

Warning: Cannot modify header information – headers already sent by (output started at /path/public_html/config.Php:31) 在/道路/ public_html/index.php on line 175.

Warning: session_start() [function.session-start]:不能发送 session cookie – headers already sent by (output started at /path/public_html/config.Php:31) 在/道路/ public_html/系统/图书馆/session.php on line 11.

Warning: session_start() [function.session-start]:不能发送 session cache limiter – headers already sent (output started at /path/public_html/config.Php:31) 在/道路/ public_html/系统/图书馆/session.php on line 11.

Solution:

Download the file mentioned in the error message and apply the solution bellow:

  1. Remove spaces 在文件的开头和结尾.

    
    
    echo "remove all space or line-break before ";
    ?>

    Common OpenCart errors and ways to solve themimages5

  2. Save the file with Notepad++ or other editor (将文件编码为ANSI或 UTF-8 without BOM):

    Common OpenCart errors and ways to solve themimages6

  3. 重新将文件上传到服务器 FTP in ASCII mode, not binary.

Issue 5. Session Issue

The PHP session stores the user information on the server for later use (i.e. 登录状态,购物项目等.). 在大多数情况下 session Issue抛出错误消息. But when there are no error messages mentioned, there are some cases of indication of the session issue:

-购物车中的产品自动清理;

– Products in the cart get cleared after the user logs into;

– OpenCart admin keeps asking to log in and there is the message ‘Invalid token session. 请再次登录。”.

Error variants:

Warning: session_start () [function.session-start]: open (/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: No such file or directory (2)在/path/public_html/system /library /session.PHP在第11行;

Warning: session_start () [function.session-start]: open (/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: Permission denied (13) 在/道路/ public_html/system /library /session.PHP在第11行;

Warning: session_start() [function.session-start]: open(/tmp/sess_41abirkdiesf9efwej46wtib2, O_RDWR) failed: No space left on device (28) 在/道路/ public_html/ /图书馆/上传/系统session.php on line 11.

Solutions:

No such file or directory issue:

  1. Open php.ini 并在下面添加代码:

    session.保存路径= /tmp;
  2. If the solution above does not work, please contact your hosting provider 问他们如何设置 session.save_path.

Other errors:

  1. “没有权限” error. Ask your hosting to check the session directory permissions.

  2. “设备上没有剩余空间” error. Ask your hosting if this is the server issue or if you need to upgrade to the package with more hosting space.

Issue 6. 允许的内存耗尽

This error occurs when your memory is not enough to execute the php code. 这意味着。使用的内存 PHP script exceeded the value of the memory_limit configuration option.

Error variants:

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 47200 bytes) 在/道路/ public_html/系统/图书馆/形象.php on line 34;

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13069817 bytes) 在/道路/ public_html/系统/图书馆/邮件.PHP在第144行;

Fatal error: Out of memory (allocated 33554432) (tried to allocate 14024 bytes) 在/道路/ public_html/library/image.php on line 34.

Solutions:

将以下解决方案之一应用于 提高极限 to 64MB, 128MB, 256MB or 512MB depending on your host.

  1. Increase the memory limit value in php.ini file:

    memory_limit = 128M;
  2. 或者将下面的代码添加到 .htaccess file:

    php_value memory_limit 128M
  3. If you get this issue quite often and the solution above does not work, please contact your hosting provider.

Issue 7. 限制生效

您将得到一条错误消息 “安全模式限制生效”. 这是一个PHP限制问题. This issue is not related to OpenCart or a template but is related to your server configuration.

Error Variants:

Warning: session_start() [function.session-start]:安全模式限制生效. The script whose uid is 10025 is not allowed to access /path/public_html/系统/图书馆/session.PHP在第11行;

Warning: imagejpeg() [function.imagejpeg]:安全模式限制生效. The script whose uid is 10305 is not allowed to access /path/public_html/image/cache/path/public_中uid 48所属的/datahtml/系统/图书馆/形象.php on line 44;

Warning: is_dir(): open_basedir限制生效. 文件路径(/ / public_html/image/87cngmlc22pe96fof5fhmq9c290phri7) is not within the allowed path(s): (/path/server/) 在/道路/ public_html/ /目录/控制器checkout/confirm.PHP在第248行.

Solutions:

  1. Since this is a server issue, asking your host to turn off the restriction is the best way to fix it.

  2. But in case you want to try to resolve it on your own, please add this piece of code to php.ini:

    safe_mode =关闭;
  3. 或者把代码写在下面 .htaccess:

    Php_value safe_mode关闭

本教程到此结束. Now you know how to resolve the common Opencart errors.

高级OpenCart主题
这个条目被张贴了出来 OpenCart教程 and tagged error, opencart, resolve. Bookmark the permalink.

提交罚单

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: 提交罚单