Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Problem deleting JUST categories. Headers already sent.


maz

Recommended Posts

Posted

Hi

Each time I delete a category I get the following message:

 

Warning: Cannot set time limit in safe mode in /home/virtual/site21/fst/var/www/html/catalog/admin/includes/functions/general.php on line 713

 

Warning: Cannot add header information - headers already sent by (output started at /home/virtual/site21/fst/var/www/html/catalog/admin/includes/functions/general.php:713) in /home/virtual/site21/fst/var/www/html/catalog/admin/includes/functions/general.php on line 18

 

IfI click back on browser everything is ok and the category is indeed deleted. But I dont want this error message occuring.

 

From the forums I know the problem lies in an extra space or line either in front of the opening php function or after the ending php function.

 

I have gone through so many files deleting the spaces and extra lines. There were so many. I was using SNAPSHOT_20030511.

 

BUT I STILL get this error. THIS ERROR ONLY OCCURS WHEN DELETING CATEGORIES. If I delete products everything is ok.

 

Does anyone know why this is occurring JUST with the category deletion. Which files should i be looking at to pin point these white spaces. I am sure i've gone through the lot!

 

Any hep will be appreciated.

 

Thanks

 

Best Regards

 

Mazhar

Posted

The file you need to look at is admin/categories.php and find the section in the switch block at the top where action = delete category.

 

In that section or before it is where your problem is. ;)

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

Hi Jim. Thanks for responding.

 

Sorry to be a pain, but I can't find 'action=delete category' as you mentioned.

 

I even tried uploading a fresh categories.php from the latest snapshot and one from an older one, but no joy. I could mail you the page if you want.

 

Here is the code for the top switch part of admin/categories.php

 

 

<?php

/*

$Id: categories.php,v 1.140 2003/03/24 12:00:23 thomasamoulton Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

if ($HTTP_GET_VARS['action']) {

switch ($HTTP_GET_VARS['action']) {

case 'setflag':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {

if ($HTTP_GET_VARS['pID']) {

tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath']));

break;

case 'insert_category':

case 'update_category':

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

$sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

 

$sql_data_array = array('sort_order' => $sort_order);

 

if ($HTTP_GET_VARS['action'] == 'insert_category') {

$insert_sql_data = array('parent_id' => $current_category_id,

'date_added' => 'now()');

$sql_data_array = tep_array_merge($sql_data_array, $insert_sql_data);

tep_db_perform(TABLE_CATEGORIES, $sql_data_array);

$categories_id = tep_db_insert_id();

} elseif ($HTTP_GET_VARS['action'] == 'update_category') {

$update_sql_data = array('last_modified' => 'now()');

$sql_data_array = tep_array_merge($sql_data_array, $update_sql_data);

tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', 'categories_id = '' . $categories_id . ''');

}

 

$languages = tep_get_languages();

for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {

$categories_name_array = $HTTP_POST_VARS['categories_name'];

$language_id = $languages[$i]['id'];

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

if ($HTTP_GET_VARS['action'] == 'insert_category') {

$insert_sql_data = array('categories_id' => $categories_id,

'language_id' => $languages[$i]['id']);

$sql_data_array = tep_array_merge($sql_data_array, $insert_sql_data);

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);

} elseif ($HTTP_GET_VARS['action'] == 'update_category') {

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', 'categories_id = '' . $categories_id . '' and language_id = '' . $languages[$i]['id'] . ''');

}

}

 

if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_image->filename . "' where categories_id = '" . tep_db_input($categories_id) . "'");

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));

break;

case 'delete_category_confirm':

if ($HTTP_POST_VARS['categories_id']) {

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

$categories = tep_get_category_tree($categories_id, '', '0', '', true);

$products = array();

$products_delete = array();

 

for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {

$product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $categories[$i]['id'] . "'");

while ($product_ids = tep_db_fetch_array($product_ids_query)) {

$products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];

}

}

 

reset($products);

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

$category_ids = '';

for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) {

$category_ids .= ''' . $value['categories'][$i] . '', ';

}

$category_ids = substr($category_ids, 0, -2);

 

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $key . "' and categories_id not in (" . $category_ids . ")");

$check = tep_db_fetch_array($check_query);

if ($check['total'] < '1') {

$products_delete[$key] = $key;

}

}

 

 

Thank for your help. Best regards

Mazhar

Posted

My apologies, the action is listed as

case 'delete_category_confirm':

and is on line 79 in your file.

 

To be honest, after all of the time you have spent and the aggravation that you probably now have, it would have been easier to download osC and just copy the admin/categories.php file.

 

It just is not worth the hassle to try and find a whitespace character. That is just my opinion.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Posted

Hi Jim

Thanks for your reply.

You are absolutely right. But that's what I did. I replaced the file with a fresh copy from the latest snapshot, and again from one of my sites which is ok, then I downloaded a copy of os2.2m1 and sent a copy from there too. Lastly, I deleted the site completely and have just uploaded the os2.2 ms1 instead of the sanapshot i was using.

 

Again the same problem. I get the error message. (even though the categories ARE being deleted and the store works fine).

 

The one thing I did notice is when installing the MS2 I did get an error during the installation which simply refered to the safe mode:

 

Warning: Cannot set time limit in safe mode in /home/virtual/site21/fst/var/www/html/catalog/admin/includes/functions/general.php on line 713

 

I just ignored this not knowing how to fix it, carried on installing and everything still works fine... except for this 'category deletion thing'. Could this have anything to do with my errors??

 

Finally, I compared the line case 'delete_category_confirm': as you suggested with other downloads and it seems OK (i think). You can see this from my previous mail.

 

Just cant explain why its doing this.

 

 

Regards

 

Mazhar

Posted

Thanks Jim

 

Ive just sorted the problem.

 

You have to comment out the instruction in general.php on line 703.

 

 

/*

if (!get_cfg_var('safe_mode')) {

set_time_limit($limit);

}

*/

 

 

The second error 'headers already sent etc' is caused by the first error which refers to the 'safe mode'. Fix the safe mode error and all is fine.

 

Thanks again for your help

 

Regards

 

Mazhar

Archived

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

×
×
  • Create New...