Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: reset(): Passed variable is not an array or object


devint

Recommended Posts

Posted

Hi

 

Recently I deleted all languages except English default and I've got a warnning that is strange to me:

Warning: reset(): Passed variable is not an array or object in /shop/index.php on line 344

and next:

Warning: Variable passed to each() is not an array or object in /shop/index.php on line 345

 

the code responsible for the warning is:

<?php 
 reset($lng->catalog_languages);
 while (list($key, $value) = each($lng->catalog_languages)) {
echo '<link rel="alternate" type="application/rss+xml" title="' . STORE_NAME . ' ' . BOX_INFORMATION_RSS . ' ' . $value['name'] . '" href="' . FILENAME_RSS . '?language=' . $key . '" />';
 }
 ?>

 

Another problem is how to insert a search query in the osCommerce forum search engine when I need to use words shorter than 3 characters???

I was trying to use quotes but it doesn't work. I must have been doing something wrong...

 

thanks for replies

Posted

To avoid those errors, you should at least surround that code in an is_array():

 

<?php 
if( is_array( $lng->catalog_languages ) ) {
 reset($lng->catalog_languages);
 while (list($key, $value) = each($lng->catalog_languages)) {
echo '<link rel="alternate" type="application/rss+xml" title="' . STORE_NAME . ' ' . BOX_INFORMATION_RSS . ' ' . $value['name'] . '" href="' . FILENAME_RSS . '?language=' . $key . '" />';
 }
}
 ?>

 

Second, we'd need to see more code for this. Where is $lng created? Right after the <?php, add this line:

 

var_dump($lng);

 

it will give some more information about your variable.

 

 

Instead of using the board search functions, I would recommend Google. You can use the site keyword to tell Google to only search the boards.

 

"terms site:www.oscommerce.com/forums"

Contributions

 

Discount Coupon Codes

Donations

Archived

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

×
×
  • Create New...