zen cart Warning: session_start() No such file or directory (2) in /dir/public_html/includes/functions/sessions.php on line 102

The error comes up when trying to use file based session storage instead of database. Apparently, the configuration for what directory to store the session is not in the configuration files but in the database table “configuration”.

If you upgrade your php to version 5.2.1, the database session storage breaks. Therefore, I had to switch to file system based storage. But the catch was that I no longer could log into admin as the session could not start. The configuration.php files did not have this constant.

The way to fix this is to log into your database and update the session directory record.

“UPDATE configuration SET configuration_value=’/your/new/direcotory/’ WHERE configuration_title=’session directory’;”

System Specs:
php.5.2.1
zencart 1.3.5
apache 1.3.37
MySQL 5.0.45

Apache SSL IfDefine – Error

Just encountered a problem that was painful to deal with while configuring SSL on apache for linux.  The httpd.conf had a tag, , before all the SSL configuration lines.  In order for any commands within and to be loaded on service start, you must use the -D attribute like this.

$ service httpd -D SSL -k start

Also, I found that restart does not always take new changes to my conf files.

$ service httpd -D SSL -k restart

Instead, use the stop then the start command to be sure.

$service httpd -D SSL -k stop
$service httpd -D SSL -k start

That was a source of much pain while working on this particular server.

Zencart and Ultimate URL – 1054 Unknown column ‘c.parent_id’ in ‘on clause’

Configuration:

Linux
Apache 1.3
Mysql 5
PHP 5
Zencart 1.3.5
Chemo Ultimate URL for Zencart 1.3.5

Problem:

After installation, the error message
1054 Unknown column ‘c.parent_id’ in ‘on clause’
shows up on any page in the catalog.

Fix:

Make the following change to /include/classes/seo.url.php
Original:

SELECT c.categories_id as id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName
FROM “.TABLE_CATEGORIES.” c,
“.TABLE_CATEGORIES_DESCRIPTION.” cd
LEFT JOIN “.TABLE_CATEGORIES_DESCRIPTION.” cd2
ON c.parent_id=cd2.categories_id AND cd2.language_id='”.(int)$this->languages_id.”‘
WHERE c.categories_id=cd.categories_id
AND cd.language_id='”.(int)$this->languages_id.”‘”;

Change:

“SELECT c.categories_id as id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName
FROM
“.TABLE_CATEGORIES_DESCRIPTION.” cd,
“.TABLE_CATEGORIES.” c
LEFT JOIN “.TABLE_CATEGORIES_DESCRIPTION.” cd2
ON c.parent_id=cd2.categories_id AND cd2.language_id='”.(int)$this->languages_id.”‘
WHERE c.categories_id=cd.categories_id
AND cd.language_id='”.(int)$this->languages_id.”‘”;

Zen Cart New Product Type Using Ultimate SEO URL Package

This post is to help those who are using Zen Cart and are using new product types with Ultimate SEO URL package installed. There are a couple of things to change in order to make everything work together as it took me a couple of hours to figure out. I hope this will help others save these couple of hours of hair pulling.

Prerequisite:

Zen Cart installed
New product type added
Ultimate SEO URL package installed
Goal:

Have the URLs for the products using the new product type show URLs in this format.

http://www.domain.com/[product name]-p-[product id].html

Changes Required:

NOTE: [handler_name] is the new product type name added.

  1. File – seo.url.php
    Original:
    $seo_pages = array(
    FILENAME_DEFAULT,
    FILENAME_PRODUCT_INFO,
    FILENAME_POPUP_IMAGE,
    FILENAME_PRODUCT_REVIEWS,
    FILENAME_PRODUCT_REVIEWS_INFO,
    );Result:

    $seo_pages = array(
    FILENAME_DEFAULT,
    FILENAME_PRODUCT_INFO,
    FILENAME_POPUP_IMAGE,
    FILENAME_PRODUCT_REVIEWS,
    FILENAME_PRODUCT_REVIEWS_INFO,
    FILENAME_[handler name]_INFO
    );
  2. File – seo.url.php
    Original:
    $this->reg_anchors = array(
    ‘products_id’ => ‘-p-‘,
    ‘cPath’ => ‘-c-‘,
    ‘manufacturers_id’ => ‘-m-‘,
    ‘pID’ => ‘-pi-‘,
    ‘products_id_review’ => ‘-pr-‘,
    ‘products_id_review_info’ => ‘-pri-‘,Result:
    $this->reg_anchors = array(
    ‘products_id’ => ‘-p-‘,
    ‘cPath’ => ‘-c-‘,
    ‘manufacturers_id’ => ‘-m-‘,
    ‘pID’ => ‘-pi-‘,
    ‘products_id_review’ => ‘-pr-‘,
    ‘products_id_review_info’ => ‘-pri-‘,
    ‘[handler name]_id’ => ‘-pji-‘,

  3. File – seo.url.php -> function parse_parameters
    Find “case ‘products_id’:”
    Within this case statement, add the following.case ($page == FILENAME_[handler name]_INFO):
    $url = $this->make_url($page, $this->get_product_name($p2[1]), ‘[
    handler_name]_id’, $p2[1], ‘.html’, $separator);
    break;
  4. File – [webroot]/includes/filenames.php
    Add the following definition.define(‘FILENAME_[handler name]_INFO’, ‘[handler name]_info’);
  5. File – [webroot]/.htaccess
    Add the following rewrite rule.RewriteRule ^(.*)-pji-(.*).html$ index\.php?main_page=[
    handler_name]_info&products_id=$2&%{QUERY_STRING} [L]

Beware duplicate mail()’s in PHP/Firefox

Strangely, invoking the PHP SMTP mail() function after outputting any HTML within a PHP page will cause Firefox to intepret the PHP command twice, thereby sending out 2 duplicate emails. This was happening using PHP5, FF1.5, and Windows IIS6. The issue is fixed by simply placing the mail() command as the first part of any script, before any headers or output are called. I cannot ascertain yet why this is occurring. Any ideas, anyone?

Fatal error: Cannot use string offset as an array in …

PHP5 Error message that is caused by attempting to assign a value to an array element of a variable that is declared as a string.

Example that generates error:
$foo=’bar’;
$foo[0]=’bar’;
Get error message Fatal error: Cannot use string offset as an array in …

Explanation
$foo was declared as a string in $foo=’bar’.
$foo[0] is trying to append an element onto a string variable.

Example that does not generate error:
$foo[0]=’bar’;
$foo=’bar’;
Does NOT generate error.

Explanation
$foo[0]=’bar’ instantiates variable $foo as array since it has not been instantiated. Then assigns ‘bar’ to element $foo[0].
$foo=’bar’ implicitly re-declares $foo as a string and assigns ‘bar’ to it.

Example that does not generate error:
$foo=’bar’;
$foo=array();
$foo[0]=’bar’;

Explanation
$foo=’bar’ implicitly declares $foo as a string variable then assigns ‘bar’ as the value.
$foo=array() explicitly re-declares $foo as an array.
$foo[0]=’bar’ can now be executed as $foo is declared as an array.

Let me know if this helped you or if I am not clear on anything. Thanks.