Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Array Error - Tried to fix


alfaowner

Recommended Posts

Hello, I ve been reading for a while before registering today, I wonder if you friendly lot have experienced the following errors that I will describe. I did search for this error before posting.

 

 

On the entry page of our OS shop (/catalog) I recieve this error as displayed below:

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 31

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 38

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 31

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 38

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 31

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 38

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 31

 

Warning: Wrong datatype for second argument in call to in_array in /home/alfaow/public_html/catalog/includes/boxes/categories.php on line 38

 

 

The error is showing where the category link usually are.

 

The first problem is that I cannot find anything wrong on lines 31 and 38

The second problem is that it does not happen on every computer that I look on, for instance, my Win 2K Operating system displays the shop okay, however, my xp proffesional system shows the error, but if I then click on a product picture, it takes me to the product okay and with no errors, but I fi go back to the front page again, I get the error again?

 

Its driving me mad, I want to out our actinic ASAP, PLease help, I am ready to ditch OS as I need to get the e-com store online before BTCC starts here in April. :shock:

 

Regards

 

AO

Link to comment
Share on other sites

I don't know what's causing it, but I did notice one thing. The first time I viewed your site it looked ok. Every time after that I got the error. So I went into my cookies and deleted the one from your site. When I brought up your site again it was ok. It's only when someone goes to your site with your cookie on their machine that the error occurs.

 

Also, there may not be an error in lines 31 and 38. Probably lines 31 and 38 are looking for something and not finding it. The error says "Wrong datatype for second argument in call to in_array". I don't know much about this stuff, but it looks like the second argument in call to in_array is $id. So $id is the wrong datatype. I don't know what any of this stuff means. It's just what I see. I hope this helps a little.

Link to comment
Share on other sites

Thanks for looking, I deleted my cookie also and found that it was fine. Is this an OS issue or a web server?

 

Any one else please feel free to give some advice, i done so much work to learn this php, but this is just way above me I think.

 

Thanks again greree

Link to comment
Share on other sites

Just for kicks, why don't you post lines 20 through 40 from your categories.php file for us to take a look at.

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

I posted the complete file just in case you saw something obvious

<?php

/*

 $Id: categories.php,v 1.2 2002/11/29 00:31:55 wilt Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 function tep_show_category($counter) {

   global $foo, $categories_string, $id;



   for ($a=0; $a<$foo[$counter]['level']; $a++) {

     $categories_string .= "  ";

   }



   $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 .= '->';

   }



   $categories_string .= '</a>';



   if (SHOW_COUNTS == 'true') {

     $products_in_category = tep_count_products_in_category($counter);

     if ($products_in_category > 0) {

       $categories_string .= ' (' . $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, true);



 $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>

<!-- categories_eof //-->

 

Thanks

Link to comment
Share on other sites

Well, sorry, I don't see anything there.

 

I also don't get the error you were talking about on IE6.

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

You can try asking questions on another forum. There are hundreds of PHP forums on the web and on usenet. I've asked questions on alt.php and gotten help. There's also an osCommerce forum at www.oscdox.com.

Link to comment
Share on other sites

Okay, just incase some one else searches for this, Here is the answer.

 

I found out how to stop it, but not why.

I had my cache enabled, once I switched that off, it worked fine, however, I did notice no /tmp/ dir I ve added it and set 777 permissions, still no joy.

 

Well, at least the error has now gone. Thankls for the help people.

 

AO

Link to comment
Share on other sites

  • 1 month later...

This blasted error is now back all on its own, however, slightly different now.

 

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

 

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

 

What the hell is this error? What does it mean? This is destroying the possibility of me ever going LIVE!!!

 

Ideas anyone please?

www.alfaowner.com/catalog Please visit it twice, it seems to pop up mostly on the second visit I am told!?

 

Thanks people.

Link to comment
Share on other sites

scary stuff this is.

 

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /Users/moyashi/Sites/osc_2.2/catalog/includes/boxes/categories.php on line 31

 

 

All was fine until just now. I put my machine to sleep woke it up and got errors. :roll: and to think of all the tinkering I've done with osC within the past 2 months ... I get an error now. :shock: and "no" I haven't touched that file so "errors" would be on osC and not me :wink:

 

Gonna try to do the cache thing. I wonder if this is a bug with osC and something else dealing with the underling system ???

NewsDesk(934) / FAQDesk(1106) / OrderCheck(1168) :::

Link to comment
Share on other sites

Well, this is not intended to be nasty to you at all... But I feel better that someone else has got this problem now, I am baffled about it. Just doesn't make sense to me. And when that happens, I simply blame microsoft and its IE6 / P3P compliant cookies. I am damn sure of it!

 

But then... !??! :oops:

 

:lol: :lol: :lol:

Link to comment
Share on other sites

I just posted in another thread with the same topic.

 

Apparently, this is happening and probably has been just written off as browser cache problems.

 

I'm using OSX 10.2.4 with Camino 7.0 ... funny thing was that I fired up Mozilla and things were working. Now, which is gonna bug me is that I have to close out my browser to see if it's just cache. (I've got like 20 tabs open too :roll: ).

NewsDesk(934) / FAQDesk(1106) / OrderCheck(1168) :::

Link to comment
Share on other sites

OK, I just restarted my browser.

 

I had both MS1 and Loaded 5 running in different tabs. Both went down at the same time.

 

hmmmm .... no why would 2 different areas go at once?

NewsDesk(934) / FAQDesk(1106) / OrderCheck(1168) :::

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...