Jump to content



Latest News: (loading..)

- - - - -

Wrong datatype for second argument...


  • Please log in to reply
6 replies to this topic

#1   blaine109

blaine109
  • Members
  • 85 posts
  • Real Name:Blaine

Posted 19 August 2012 - 04:29 PM

I am getting the error below:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/****/public_html/includes/boxes/categories.php on line 36
Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/****/public_html/includes/boxes/categories.php on line 43

This error is looped about 7 times and then it starts to display my categories as normal in the categories box.

Line 36 of boxes/categories.php
	if ( ($id) && (in_array($counter, $id)) ) {
	  $categories_string .= '<b>';
	}

Line 43 or boxes/categories.php
	if ( ($id) && (in_array($counter, $id)) ) {
	  $categories_string .= '</b>';
	}

Now, I only get this error when I have clicked on a manufacturer from the manufacturers box.  I do have a heavily modified store and was updating a Header Tags contribution when this error started to show up.  I asked in the help forum for that contribution but was told that the contribution did not affect the boxes/categories.php file so now I am posting my issue here.  What other files are associated with those lines of code?  If I can find out I may be able to backtrace my error.

I am running v2.2RC2a and have done the upgrade to make is equivalent to v2.3.0.
Current PHP version is 5.2.17

Thanks,
Blaine

#2   kymation

kymation

    Believers

  • Community Sponsor
  • 6,682 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 August 2012 - 05:21 PM

That code doesn't exist in stock osCommerce, so it's something you added. The problem is that it's badly coded: It doesn't test $id for the proper data type (array) and $id is not being set properly. You'll have to trace it back and find where the error is occurring.

Regards
Jim

Edited by kymation, 19 August 2012 - 05:25 PM.

My Addons

Banners Box 2.3.x  Support
Categories Accordion Box 2.3.x  Support
Categories Images Box 2.2x  2.3.x  Support
Closest Shipper 2.2x  Support
Document Manager 2.2x  Support
Generic Box 2.3.x  Support
Get 1 Free 2.2x  Support
jQuery Banner Rotator 2.2x  2.3.x  Support
Modular Front Page 2.3.x  Support
Modular SEO Header Tags 2.3.x  Support
MVS 2.2x  Support
PDF Datasheet 2.3.x  Support
Price Updater 2.2x
Products Specifications 2.2x  2.3.x  Development Version  Support  Bugs/Suggestions
Request a Review 2.2x - 2.3.x  Support
Similar Products Box 2.2x
Specials Image Overlay 2.3x Support
Theme Switcher 2.3.x  Support

#3   blaine109

blaine109
  • Members
  • 85 posts
  • Real Name:Blaine

Posted 19 August 2012 - 10:40 PM

This file has never been modified with any contributions.  The only thing I believe that has been done to it is to remove the "corners" of the categories box I believe.  The issue, I think, lies in the code trying to find a category to highlight in bold.  Problem is, when you click on a manufacturer you are not in any specific category and therefore I belive I am getting an error because it is trying to use some array data to find the category that you are in.  When you click on a product from that listing and go to the products page the errors go away and the code is properly highlighting the category that the clicked item is in.

Here is the entire file:

<?php
/*
  $Id: categories.php,v 1.23 2002/11/12 14:09:30 dgw_ Exp $
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Copyright (c) 2002 osCommerce
  Released under the GNU General Public License
*/
if ( (USE_CACHE == 'true') && !defined('SID')) {
	echo tep_cache_categories_box();
  } else {

  function tep_show_category($counter) {
	global $foo, $categories_string, $id;
	for ($a=0; $a<$foo[$counter]['level']; $a++) {
	  $categories_string .= "&nbsp;&nbsp;";
	}
	$categories_string .= '<a href="';
	if ($foo[$counter]['parent'] == 0) {
	  $cPath_new = 'cPath=' . $counter;
	} else {
	  $cPath_new = 'cPath=' . $foo[$counter]['path'];
	}
	$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);
	$categories_string .= '">';
	if ( ($id) && (in_array($counter, $id)) ) {
	  $categories_string .= '<b>';
	}
// display category name
	$categories_string .= $foo[$counter]['name'];
	if ( ($id) && (in_array($counter, $id)) ) {
	  $categories_string .= '</b>';
	}
	if (tep_has_category_subcategories($counter)) {
	  $categories_string .= '-&gt;';
	}
	$categories_string .= '</a>';
	if (SHOW_COUNTS == 'true') {
	  $products_in_category = tep_count_products_in_category($counter);
	  if ($products_in_category > 0) {
		$categories_string .= '&nbsp;(' . $products_in_category . ')';
	  }
	}
	$categories_string .= '<br>';
	if ($foo[$counter]['next_id']) {
	  tep_show_category($foo[$counter]['next_id']);
	}
  }
?>
<!-- categories //-->
		  <tr>
			<td>
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
							   'text'  => BOX_HEADING_CATEGORIES
							  );
  new infoBoxHeading($info_box_contents, true, false);
  $categories_string = '';
  $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='" . $languages_id ."' order by sort_order, cd.categories_name");
  while ($categories = tep_db_fetch_array($categories_query))  {
	$foo[$categories['categories_id']] = array(
										'name' => $categories['categories_name'],
										'parent' => $categories['parent_id'],
										'level' => 0,
										'path' => $categories['categories_id'],
										'next_id' => false
									   );
	if (isset($prev_id)) {
	  $foo[$prev_id]['next_id'] = $categories['categories_id'];
	}
	$prev_id = $categories['categories_id'];
	if (!isset($first_element)) {
	  $first_element = $categories['categories_id'];
	}
  }
  //------------------------
  if ($cPath) {
	$new_path = '';
	$id = split('_', $cPath);
	reset($id);
	while (list($key, $value) = each($id)) {
	  unset($prev_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 = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
	  $category_check = tep_db_num_rows($categories_query);
	  if ($category_check > 0) {
		$new_path .= $value;
		while ($row = tep_db_fetch_array($categories_query)) {
		  $foo[$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($prev_id)) {
			$foo[$prev_id]['next_id'] = $row['categories_id'];
		  }
		  $prev_id = $row['categories_id'];
		  if (!isset($first_id)) {
			$first_id = $row['categories_id'];
		  }
		  $last_id = $row['categories_id'];
		}
		$foo[$last_id]['next_id'] = $foo[$value]['next_id'];
		$foo[$value]['next_id'] = $first_id;
		$new_path .= '_';
	  } else {
		break;
	  }
	}
  }
  tep_show_category($first_element);
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
							   'text'  => $categories_string
							  );
  new infoBox($info_box_contents);

?>
			</td>
		  </tr>
<?php
}
?>
<!-- categories_eof //-->


#4   kymation

kymation

    Believers

  • Community Sponsor
  • 6,682 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 August 2012 - 11:51 PM

That code is from osCommerce 2.2 MS1 from nearly 10 years ago. Those bugs were fixed in 2.2 MS2 in 2003. You need to get rid of that ancient code and replace it with the box from 2.2 RC2a. Then you can make whatever changes you want to the corners.

Regards
Jim
My Addons

Banners Box 2.3.x  Support
Categories Accordion Box 2.3.x  Support
Categories Images Box 2.2x  2.3.x  Support
Closest Shipper 2.2x  Support
Document Manager 2.2x  Support
Generic Box 2.3.x  Support
Get 1 Free 2.2x  Support
jQuery Banner Rotator 2.2x  2.3.x  Support
Modular Front Page 2.3.x  Support
Modular SEO Header Tags 2.3.x  Support
MVS 2.2x  Support
PDF Datasheet 2.3.x  Support
Price Updater 2.2x
Products Specifications 2.2x  2.3.x  Development Version  Support  Bugs/Suggestions
Request a Review 2.2x - 2.3.x  Support
Similar Products Box 2.2x
Specials Image Overlay 2.3x Support
Theme Switcher 2.3.x  Support

#5   blaine109

blaine109
  • Members
  • 85 posts
  • Real Name:Blaine

Posted 20 August 2012 - 12:14 AM

Do you know where I can get a fresh copy of a 2.2RC2a includes/boxes/categories.php from?  There is no longer a download offered of 2.2 from Oscommerce.com

Thanks,
Blaine

#6   blaine109

blaine109
  • Members
  • 85 posts
  • Real Name:Blaine

Posted 20 August 2012 - 12:23 AM

I actually found one.  Going to cough that one up to a "Fantastico" install....

#7   blaine109

blaine109
  • Members
  • 85 posts
  • Real Name:Blaine

Posted 20 August 2012 - 01:22 AM

Confirmed that this was the issue.  Thank you for your help.