Jump to content
josh1r

Error with manufacturers.php

Recommended Posts

Hi.  I want to start by saying that I haven't (fortunately) been on this forum in years, as my old osc site has continued to work well over the years.  I also haven't done any development on the site in ages, so I admit I don't fully remember how osc/php/etc.. works (I was self-taught years ago and remember some of it, but not all).

In any case, sometime in the past week or so (I think, but it could have happened longer ago), something went wrong with manufacturers.php

There is now an error on my site (blueluxe.com) on the left hand nav bar which says:  Warning: Invalid argument supplied for foreach() in /home/blueluxe/public_html/includes/boxes/manufacturers.php on line 38

I haven't made any changes to my site in ages (literally months/years) so I don't think I did anything to cause this.  I asked my webhost to check php/database versions/changes and they claim they didn't cause this.

Any thoughts?

Thanks so much!

Share this post


Link to post
Share on other sites
2 minutes ago, josh1r said:

Any thoughts?

It might be a very good idea to provide this:

2 minutes ago, josh1r said:

Warning: Invalid argument supplied for foreach() in /home/blueluxe/public_html/includes/boxes/manufacturers.php on line 38

so what is the code on line 38 exactly.

 


Help shape the future of Phoenix; join the Phoenix Club

Share this post


Link to post
Share on other sites
  1. empty your cache (in admin)
    this *might* fix it
  2. check your list of manufacturers (in admin)
    all look correct?
  3. turn off the manufacturers box
    if all else fails

And, think about uprating to Phoenix, as your version is ancient.
It was EOL a decade ago...


Help shape the future of Phoenix; join the Phoenix Club

Share this post


Link to post
Share on other sites

Thanks.  Neither 1 nor 2 helped, so I'll turn it off for now.

Is there a way (probably within my hosting so I'll ask them as well, to track/log what exactly might be causing that error?

As for updating, I'm sure that's way more involved than I can handle right now.  Again, I haven't done anything on the site in ages, don't remember a lot of what I taught myself, and don't want to pay someone right now to do the update.  But I will look into it as I've never even heard of it before (that's how out of the loop of I am...!).

Share this post


Link to post
Share on other sites

ask your host, it might be because your host has upgraded the php.  

you can turn the error reporting off, see if it works? it is a warning after all.

you can see if your host can go back to the old php.

 

 

 

 

 

 

 


you can cut up to 4 pages of your checkout by using my three add_ons

login create account in one page

Express checkout  

login pop up modal

Share this post


Link to post
Share on other sites
3 hours ago, josh1r said:

Is there a way (probably within my hosting so I'll ask them as well, to track/log what exactly might be causing that error?

This isn't something a host can help you do.  It's a coding thing.  You'd hire a developer to troubleshoot. 

If you want to continue to try yourself: 

  $manufacturers = $cache->get_cache('manufacturers', 'ARRAY');
  $total_rows = count($manufacturers);
  
  if ($total_rows < 1) {

Consider commenting out these lines and the closing } and see if it works.  Or change them to

  $manufacturers = $cache->get_cache('manufacturers', 'ARRAY');
  $total_rows = count($manufacturers);
  
  if (is_array($manufacturers) && $total_rows < 1) {

You could also add

var_dump($manufacturers);

and see what it says.  That would go before the if and after the closing } for the if. 

The basic problem though is that that version is so old that there is no supported PHP for it any more. 

The simplest solution would be to turn off the box.  It doesn't work this way, so not a big deal to turn it off. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Commenting out :

//  $manufacturers = $cache->get_cache('manufacturers', 'ARRAY');
//  $total_rows = count($manufacturers);
//  
//  if ($total_rows < 1) {
    $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
    $total_rows = tep_db_num_rows($manufacturers_query);
    
    while ($man = tep_db_fetch_array($manufacturers_query)) {
      $manufacturers[] = $man;
    }
//  }

pretty much did the trick!

however, it shows manufacturers even if they have no products (not a big deal, i can live with that!)

thanks so much!

Share this post


Link to post
Share on other sites

Quick follow-up; does that fact that I commented out the lines above tell us what exactly was causing the original problem?

Share this post


Link to post
Share on other sites

It says that the cache was corrupted and not reloading.  There may have been a PHP update on your host that changed how count handled things in that case.  I have a sort of vague recall that something used to be a zero that may now be a one.  But since that code doesn't set the cache block, there's no way to fix it there. 

You might be able to fix it in whatever the $cache thing is, but I don't believe that's standard.  I think that's an App you added.  Because I recall the core caching as working differently.  Of course, that's old enough that perhaps my recall is wrong. 

You commented out the code that checks if the cache is working and falls back to a database query.  So it just always does the database query.  Because the cache was returning that it was working even though it didn't seem to be. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×