Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal error


Tormenta

Recommended Posts

Posted

I've introduced quite a few changes in the store, mainly in the header and in the footer. At present the database is in my hard disk.

 

Now when trying to login, view the shopping cart, go to the the contact page, briefly, when trying to do almost everything I get this message:

 

Fatal error: Cannot redeclare tep_show_category() (previously declared in c:\oscommerce\easyphp1-8\www\catalog\includes\header.php:240) in c:\oscommerce\easyphp1-8\www\catalog\includes\boxes\categories.php on line 13

 

The very beginning of the categories.php file is:

 

<?php

/*

$Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

function tep_show_category($counter) {

global $tree, $categories_string, $cPath_array;

 

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= "  ";

}

 

 

The header.php file is:

 

<?php

/*

$Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// check if the 'install' directory exists, and warn of its existence

if (WARN_INSTALL_EXISTENCE == 'true') {

if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {

$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');

}

}

 

// check if the configure.php file is writeable

if (WARN_CONFIG_WRITEABLE == 'true') {

if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {

$messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');

}

}

 

// check if the session folder is writeable

if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {

if (STORE_SESSIONS == '') {

if (!is_dir(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');

} elseif (!is_writeable(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');

}

}

}

 

// check session.auto_start is disabled

if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {

if (ini_get('session.auto_start') == '1') {

$messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');

}

}

 

if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {

if (!is_dir(DIR_FS_DOWNLOAD)) {

$messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');

}

}

 

if ($messageStack->size('header') > 0) {

echo $messageStack->output('header');

}

?>

<!--

 

 

 

 

<? // ---- MANUFACTURERS

 

 

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {

 

echo '<table cellspacing=0 cellpadding=0 width=177 align=center> '.

tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get')

.' <tr><td colspan=2><b>Search by manufacturers:</b></td></tr>

<tr><td height=2 colspan=2></td></tr>

<tr><td colspan=2>

';

 

$manufacturers_array = array();

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);

$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],

'text' => $manufacturers_name);

}

 

echo tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" class=se1') . tep_hide_session_id();

echo ' </td>

</form>

</table>

';

}

 

?>

 

-->

 

<table cellspacing=0 cellpadding=0 width=646 height=100% align=center>

<tr><td bgcolor=#750146 class=ch1 valign=top>

<table cellspacing=0 cellpadding=0 width=644>

<tr><td><a href=<?=tep_href_link('index.php')?>><img src=images/b01.gif width=127 height=38 border=0></a><a href=<?=tep_href_link('products_new.php')?>><img src=images/b02.gif width=128 height=38 border=0></a><a href=<?=tep_href_link('account.php')?>><img src=images/b03.gif width=128 height=38 border=0></a><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/b04.gif width=128 height=38 border=0></a><a href=<?=tep_href_link('contact_us.php')?>><img src=images/b05.gif width=133 height=38 border=0></a></td></tr>

<tr><td bgcolor=#AC4D8A height=1></td></tr>

<tr><td height=5></td></tr>

<tr><td bgcolor=#AC4D8A height=1></td></tr>

<tr><td><a href=<?=tep_href_link('index.php')?>><img src=images/m02.jpg width=307 height=112 border=0></a><img src=images/m03.jpg width=337 height=112 border=0></td></tr>

<tr><td bgcolor=#AC4D8A height=1></td></tr>

<tr><td valign=top>

<table cellspacing=0 cellpadding=0>

<tr><td width=126>

<table cellspacing=0 cellpadding=0 style="padding-left: 10px">

<tr><td class=ch2>Choose language:</td></tr>

<tr><td height=5></td></tr>

<tr><td>

<? // LANGUAGES

 

if (!isset($lng) || (isset($lng) && !is_object($lng))) {

include(DIR_WS_CLASSES . 'language.php');

$lng = new language;

}

 

$languages_string = '';

reset($lng->catalog_languages);

while (list($key, $value) = each($lng->catalog_languages)) {

$languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';

}

 

echo $languages_string;

 

?>

 

</a></td></tr>

</table>

</td>

<td background=images/m04.gif width=1 height=48></td>

<td width=126>

<table cellspacing=0 cellpadding=0 style="padding-left: 7px">

<tr><td class=ch2>Currencies:</td></tr>

<tr><td height=5></td></tr>

<form>

<tr><td>

<? // CURRENCIES

 

echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get');

 

reset($currencies->currencies);

$currencies_array = array();

while (list($key, $value) = each($currencies->currencies)) {

$currencies_array[] = array('id' => $key, 'text' => $value['title']);

}

 

$hidden_get_variables = '';

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {

$hidden_get_variables .= tep_draw_hidden_field($key, $value);

}

}

 

echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit(); "class=se style="width:110px; font-size: 9px" ') . $hidden_get_variables . tep_hide_session_id();

echo '</form>';

 

?>

 

</td></tr>

</form>

</table>

</td>

<td background=images/m04.gif width=1 height=48></td>

<td width=126>

<table cellspacing=0 cellpadding=0 style="padding-left: 7px">

<tr><td><img src=images/m08.gif width=4 height=4 align=absmiddle> ?<a href=<?=tep_href_link('account.php')?> class=ml1>Create an account</a></td></tr>

<tr><td><img src=images/m08.gif width=4 height=4 align=absmiddle> ?<a href=<?=tep_href_link('login.php')?> class=ml1>Customer Login</a></td></tr>

</table>

</td>

<td background=images/m04.gif width=1 height=48></td>

<td width=133>

<table cellspacing=0 cellpadding=0 style="padding-left: 7px">

<tr><td><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m09.gif width=24 height=25 border=0></a></td>

<td valign=top>

<span class=ch3>Shopping Cart</span><br><span class=ch4>in your cart <a class=ml5 href=<?=tep_href_link('shopping_cart.php')?>><?=$cart->count_contents()?> items</a></span>

</td></tr>

</table>

</td>

<td background=images/m04.gif width=1 height=48></td>

<td width=128>

 

<? // SEARCH ?>

<table cellspacing=0 cellpadding=0 style="padding-left: 7px">

<?=tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get')?>

<tr><td class=ch2>Quick search:</td></tr>

<tr><td height=5></td></tr>

<tr><td>

<?=tep_draw_input_field('keywords', '', 'size="20" maxlength="50" style="width=110" onclick="this.value=\'\'" value=choose_product class=se') . ' ' . tep_hide_session_id()?></td></tr>

</form>

</table>

<? // END SEARCH ?>

 

</td></tr>

</table>

</td></tr>

<tr><td bgcolor=#AC4D8A height=1></td></tr>

<tr><td height=5></td></tr>

<tr><td bgcolor=#AC4D8A height=1></td></tr>

<tr><td height=1></td></tr>

</table>

</td></tr>

<tr><td height=100% class=ch1 bgcolor=#750146 valign=top align=right>

<table cellspacing=0 cellpadding=0 width=643 align=right>

<tr><td width=170 valign=top class=ch6 align=right>

<table cellspacing=0 cellpadding=0 bgcolor=#A70167 width=169 align=right>

<tr><td height=19></td></tr>

<tr><td class=ch8><span class=ch7>Top Sales</span></td></tr>

<tr><td height=5></td></tr>

<? // ---- Bestsellers

 

$best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . 15);

if ($number_of_rows = tep_db_num_rows($best_sellers_query)) {

 

$best_array = array();

while ($bestseller = tep_db_fetch_array($best_sellers_query)) {

$output_1 .= $output ? '' : '';

$output_1 .= '<tr><td class=ch8><img src=images/m10.gif width=4 height=6 align=absmiddle> ?<a class=ml3 href=';

$products_name = ((strlen($bestseller['products_name']) > 25) ? substr($bestseller['products_name'], 0, 25) . '..' : $bestseller['products_name']);

$output_1 .= tep_href_link('product_info.php', 'products_id='.$bestseller['products_id']). '>'.$products_name;

$output_1 .= '</a></td></tr>';

}

 

echo $output_1;

}

 

?>

 

 

 

<tr><td height=14></td></tr>

<tr><td background=images/m11.gif height=1></td></tr>

<tr><td height=14></td></tr>

<tr><td class=ch8><span class=ch7>Shop by Categories</span></td></tr>

<tr><td height=5></td></tr>

 

 

 

<? // ---- CATEGORIES

 

function tep_show_category($counter) {

global $tree, $categories_string, $cPath_array;

 

if(!$tree[$counter]['level']){

 

$categories_string .= $categories_string ? '' : '';

 

$categories_string .= '<tr><td class=ch8><img src=images/m10.gif width=4 height=6 align=absmiddle> ?<a class=ml3 href=';

 

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

$categories_string .= tep_href_link('index.php', $cPath_new) . '>';

// display categry name

$categories_string .= $tree[$counter]['name'];

$categories_string .= '</a></td></tr> ';

 

}else{ // SUBCATEGORY

 

$categories_string .= '<tr><td class=ch8><img src=images/m10.gif width=4 height=6 align=absmiddle> ? ? ? ??';

 

for($i=0;$i<$tree[$counter]['le vel'];$i++)

$categories_string .= '?????';

 

$categories_string .= '??? <a class=ml3 style="font-weight:normal;" href=';

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

$categories_string .= tep_href_link('index.php', $cPath_new) . '>-';

// display category name

$categories_string .= $tree[$counter]['name'];

$categories_string .= '</a></td></tr>';

}

 

if ($tree[$counter]['next_id'] != false) {

tep_show_category($tree[$counter]['next_id']);

}

}

 

 

 

define(TABLE_CATEGORIES, "categories");

define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");

$categories_string = '';

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $categories['categories_id'];

}

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element)) {

$first_element = $categories['categories_id'];

}

}

 

//------------------------

if ($cPath) {

$new_path = '';

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {

unset($parent_id);

unset($first_id);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

if (tep_db_num_rows($categories_query)) {

$new_path .= $value;

while ($row = tep_db_fetch_array($categories_query)) {

$tree[$row['categories_id']] = array('name' => $row['categories_name'],

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $row['categories_id'];

}

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id)) {

$first_id = $row['categories_id'];

}

 

$last_id = $row['categories_id'];

}

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

$tree[$value]['next_id'] = $first_id;

$new_path .= '_';

} else {

break;

}

}

}

$categories_string .= '';

tep_show_category($first_element);

$categories_string .= '';

 

echo $categories_string;

?>

 

 

 

<tr><td height=14></td></tr>

<tr><td background=images/m11.gif height=1></td></tr>

<tr><td height=14></td></tr>

<tr><td class=ch8><span class=ch7>Shop by Brand </span></td></tr>

<tr><td height=5></td></tr>

 

<? // ---- MANUFACTURERS STRING OUTPUT

 

 

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {

 

$manufacturers_array = array();

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$output .= $output ? '' : '';

$output .= '<tr><td class=ch8><img src=images/m10.gif width=4 height=6 align=absmiddle> ?<a class=ml3 href=';

$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);

$output .= tep_href_link('index.php', 'manufacturers_id='.$manufacturers['manufacturers_id']). '>'.$manufacturers_name;

$output .= '</a></td></tr>';

}

 

echo $output;

}

 

?>

 

 

<tr><td height=14></td></tr>

<tr><td height=14></td></tr>

<tr><td class=ch8><img src=images/m10.gif width=4 height=6 align=absmiddle> ?<a href=<?=tep_href_link('products_new.php')?> class=ch7>Browse All</a></td></tr>

<tr><td height=14></td></tr>

<tr><td background=images/m11.gif height=1></td></tr>

<tr><td><a href=<?=tep_href_link('specials.php')?>><img src=images/m12.jpg width=168 height=105 border=0></a></td></tr>

<tr><td bgcolor=#750146 height=1></td></tr>

</table>

</td>

<td width=2 height=100% class=ch5><span style="padding-left: 1px"></span></td>

<td width=5></td>

<td width=466 valign=top align=right>

<table cellspacing=0 cellpadding=0 width=466>

<tr><td><a href=<?=tep_href_link('index.php','cPath=53')?>><img src=images/m13.jpg width=234 height=164 border=0><img src=images/m14.jpg width=232 height=164 border=0></a></td></tr>

<tr><td height=5></td></tr>

</table>

 

 

 

 

Can someone please tell me what is wrong with the tep_show_category code?

Posted

If you are using a template, it is because the template maker has copied that function, tep_show_category, to a file where it really shouldn't be. So you get the duplicate message. You can solve the problem by renaming the function they use. If you search the forums for that function you will find instructions on how to do this.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
If you are using a template, it is because the template maker has copied that function, tep_show_category, to a file where it really shouldn't be. So you get the duplicate message. You can solve the problem by renaming the function they use. If you search the forums for that function you will find instructions on how to do this.

 

Jack

Posted

Thanks a lot for your answer Jack. In fact I'm not using the entire template, I just took from one some changes I wanted to introduce to my site. Obviously I'm not too experienced .... :blush:

 

I will search for this information in the forum.

 

Thanks again.

Posted

See if the part you took has that function named in it. My guess is that it does. All you need to do is reanme all occurrence of that function in that code to something else. So if there are three instances of tep_show_category, change them all to tep_show_category_extra (or whatever you want to name it).

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...