Errors

From Zen Cart(tm) Wiki
Jump to: navigation, search


Also see the troubleshooting section in the FAQ/tutorials/knowledgebase.

General Troubleshooting to find odd problems

Click HERE for assistance in Diagnosing Obscure Issues

MySQL

0 ERROR_DB_NOT_CONNECTED

The most common causes are:
1. includes/configure.php database settings don't match properly to your website database credentials
2. if you have phpBB installed and the link "active" in Zen Cart™, then perhaps that database is down...or the config.php in the phpBB folder may have invalid info or is not readable?

1264 Out of range value adjusted for column 'configuration_id' at row 1

Same answer as for 1054 Unknown column ... in 'on clause'.

1054 Unknown column ... in 'on clause'

This probably means you have MySQL 5 installed on your server, and Zen Cart™ 1.2.6d does not fully support MySQL 5.
See this bug report for more info regarding issues with MySQL 5 in Zen Cart™ 1.2.6d.

This issue has largely been fixed in the version 1.3.x series, and will be improved with each release.

If you have to stick with 1.2.6, the best solution seems to be downgrading to MySQL 4.

1062 Duplicate entry 'nnnnn' for key 1

This issue was fixed in v1.2.6, but under certain circumstances (and through no fault of Zen Cart) can still occur in more recent versions.

To fix it in versions prior to 1.2.6 without upgrading:

  1. Open phpMyAdmin to access your store's database.
  2. Click on the SQL tab
  3. Paste the following into the textarea, and click Go:
ALTER TABLE admin_activity_log CHANGE COLUMN log_id log_id int(15) NOT NULL auto_increment;

If you're using a table prefix, be sure to add that to the table name in the above code.

ALTER TABLE <your prefix goes here>admin_activity_log CHANGE COLUMN log_id log_id int(15) NOT NULL auto_increment;

A similar problem can occur in any version of Zen Cart when phpMyAdmin is used to export data from a database using the "SQL export compatibility:" function. For many of the compatibility settings, in particular MYSQL, MYSQL323 and MYSQL40 certain field options such as auto_increment are supressed and will need to be added back manually or via a rebuild-script. There is an auto_increment rebuild script in the /zc_install/sql folder of the Zen Cart distribution files.

1016 Can't open file: '<table name>.MY*'. (errno: 145)

Error code 145 means: Table was marked as crashed and should be repaired

The solution is to run a repair on the appropriate table in your database.

  • Open phpMyAdmin (or any other interface to MySQL you might be using)
  • Click the SQL tab and enter this query:
    REPAIR TABLE <table name>;
    where <table name> is the table from the error message.


External links:

I have 1.3.x and MySQL strict mode still causes problems

Here is what you do before installation:

  • in a file installer.php find code
         if (@mysql_select_db($zp_name) == false) {
             $this->setError($zp_error_text.'<br />'.@mysql_error(), $zp_error_code, true);
         }

and insert line

         else @mysql_query("SET SESSION sql_mode = ''");

right after };

  • in a file query_factory.php find code
       $this->db_connected = true;
       return true;

and insert line

       @mysql_query("SET SESSION sql_mode = ''", $this->link);

right between them.

As always, this patch is not official, blah blah blah. It forces MySQL 5 to turn strict mode off before any queries were ran. Enjoy.

PHP

Warning: Cannot modify header information - headers already sent by (output started at <path/to/output_file>:<line number>) in <path/to/current_file> on line <number>

This warning is usually caused by a space or extra line at beginning or the end of a .php file.

The file name and line number you need to check are located immediately after "output started at " within the parantheses in the error message. To fix this, open that file and go to the line number as reported from the error message. Make sure nothing is output from that line.

If either
<?php
or
?>
are present at that or the previous line, remove the space immediately before '<?php' or after '?>'.

NOTE: You may also get this message if you 'checked out' files, edited, then uploaded with Dreamweaver, and did not 'check in' the files. If you 'check in' the files via Dreamweaver the error will disappear.

Idea.png Are there other errors before this one?
If the "headers already sent" error appears after any other error, then you need to fix that other error first. (The error message itself is what caused headers to be sent, so fixing that error will cause the second error to go away too.)

Warning: Variable passed to each() is not an array or object in ... includes/application_top.php on line 682

There have been many slightly different reports in v1.2.6d related to this error message. Here are some: #1, #2, #3
These issues have been fixed in version 1.3.


Fix for 1.2.6d:

  1. Open includes/modules/product_listing.php
    1. Replace
        if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
   // bof: multiple products
   $how_many = 0;
   echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
}with
    $how_many = 0;
    1. Replace
                    if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
               $how_many++;
               $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=0 size=\"4\">";
             } else {
               $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}with
              if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
               $button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . $listing->fields['products_id'] . "'");
               if (
                   // product type can be added to cart
                   zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
                   &&
                   // product is not call for price
                   $button_check->fields['product_is_call'] == '0'
                   &&
                   // product is in stock or customers may add it to cart anyway
                   ($button_check->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == '0')
               )
               {
                   $how_many++;
               }
               $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=0 size=\"4\">";
             } else {
               $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
    1. Replace the end of the file:
      ?>
<?php require($template->get_template_dir('tpl_modules_product_listing.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_product_listing.php'); ?>with
  if ($how_many > 0 and PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0) {
   // bof: multiple products
   echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
 }

?>

<?php require($template->get_template_dir('tpl_modules_product_listing.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_product_listing.php'); ?>
  1. Open
    • includes/templates/template_default/templates/tpl_featured_products_default.php
    • includes/templates/template_default/templates/tpl_products_all_default.php
    • includes/templates/template_default/templates/tpl_products_new_default.php
      In all these files, replace
              $how_many++;
      with
      			$button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . $check_products_all->fields['products_id'] . "'");

if ( // product type can be added to cart zen_get_products_allow_add_to_cart($check_products_all->fields['products_id']) != 'N' && // product is not call for price $button_check->fields['product_is_call'] == '0' && // product is in stock or customers may add it to cart anyway ($button_check->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == '0') ) { $how_many++; }

Warning: Variable passed to each() is not an array or object in .../includes/classes/db/mysql/query_factory.php on line 100

Check your phpinfo and see if magic_quotes_runtime is enabled; if so, you need to turn it off.

This can be done by adding the following lines

if (get_magic_quotes_runtime())
{
	set_magic_quotes_runtime(0);
}

to these files, right after the license info:

includes/application_top.php
admin/includes/application_top.php

If this doesn't help, please use the discussion page for this wiki page or consult the forums.


Warning: main(<...>): failed to open stream: No such file or directory in <...>

First make sure you have uploaded all files - specifically the file in question - and set correct permissions.

If that doesn't fix it, check your PHP include_path, which should be listed along with the error message you got. You can also check this setting with phpinfo().

On a windows server, the include_path needs to start with
.;
and on a *nix server, it must start with
.:

If the include_path does not contain this, you must configure it in php.ini or in a .htaccess file. If in doubt about how to do this, ask your host.

  • php.ini
    For Windows:
    include_path = ".;Drive:\path\to\php\includes"
    For *nix:
    include_path = ".:/path/to/php/includes"
  • .htaccess
    For Windows:
    php_value include_path ".;Drive:\path\to\php\includes"
    For *nix:
    php_value include_path ".:/path/to/php/includes"


Warning: open_basedir restriction in effect

Warning: <restricted function>: open_basedir restriction in effect. File(<path to file>) is not within the allowed path(s): (<allowed paths>) in <file producing the error> on line <line>

PHP manual entry

This error means that you're trying to use a directory which you don't have access to on your server. Make sure Zen Cart™ is configured to use only the directories listed in the error message after 'File(...) is not within the allowed path(s):'. Directories are separated with a colon (:) on *nix servers, and with a semi-colon (;) on windows servers. The listed directories are prefixes, not necessarily real directories; eg. if '/path/to' is an allowed path, then so is '/path/to/some/dir' and '/path/tool/' too.

Browser

Redirection limit for this URL exceeded. Unable to reach the requested page. This may be caused by cookies that are blocked.

Some users have experienced this error when attempting to log in to Admin. This has been known to have been caused by having an extra slash in your configure.php files.
Change:

      define('HTTP_SERVER', 'http://myserver.com/');

To:

      define('HTTP_SERVER', 'http://myserver.com');

This page contains both secure and non-secure items

Users experience this warning when an unsecure absolute address has been used to display an image(s) on a secure page. To determine the origin of the error, View Source on the affected page and look for an image being refferenced at http rather than https on the secure page. This is most common when users have edited their header or footer files to display custom images but have not used a relative path to the image. As an example the user would replace:

<img src="http://www.yourdomain.com/includes/templates/YOUR_TEMPLATE/images/your_image.gif />

with:

<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'your_image.gif','Your Alt Text'); ?>

or:

<img src="includes/templates/YOUR_TEMPLATE/images/your_image.gif" />


Other

<div id="You_entered_the_wrong_username_or_password" />

You entered the wrong username or password.

If you can't remember your admin account or password, there's still hope.

The first thing you can try is to click the "Resend Password" button and enter the admin email address.

If for some reason that doesn't work for you, you can create a temporary admin account in order to log in.

Open phpMyAdmin, click the "SQL" tab and run this query:

DELETE FROM admin WHERE admin_name = 'Admin';
INSERT INTO admin (admin_name, admin_email, admin_pass, admin_level) VALUES ('Admin', 'admin@localhost', '351683ea4e19efe34874b501fdbf9792:9b', 1);

If you are using a prefix for your database tables, you'll naturally need to add that prefix to the table name above. Ie. "... FROM/INTO <prefix_>admin ...".
You should now be able to login using the following details:

Username: Admin
Password: admin

Be sure to use proper case. Ie. 'Admin' for username, not 'admin'.


After you log in, remember to delete this temporary admin account and create a new one from

Admin - Tools - Admin Settings


If you require a more drastic method, you could try the table-rebuild suggestion in this post (related to v1.3.5): Rebuilding the admin logins table

Warning: session.auto_start is enabled - please disable this php feature in php.ini and restart the web server.

You can disable this setting in php.ini or a .htaccess file.

php.ini

If you have access to this file, set the directive session.auto_start to 0.

session.auto_start = 0

.htaccess

If you can use .htaccess files, create one in your zen cart dir unless it already exists, and add this to it:

php_value session.auto_start 0


Or you can also contact your host and ask them to fix it for you.