Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HTML arrays and PHP


Guest

Recommended Posts

This is more of a general PHP question but came up due to an OSCommerce installation. I installed OSCommerce to my local machine with apache, php, and mysql. It works great. When I upload the site to another web-server, suddenly the product attributes and a few other features break. I have traced the problem to HTML/PHP array handling. As you may or may not know you can pass a form variable into a PHP array by adding the '[ brackets ]' to the end of it: <select name="myarray[]'>

 

In fact the product attributes are handled this way in OSCommerce. The web server chokes on these and throws an error in the foreach statement saying the object is not an array. On my home server however, it works fine. Does anyone know if this is a PHP.INI problem or something else? The administrator doesn't know anything about anything, so I am at a loss. I can't seem to find the right search string to find any info on this but it seems like a simple enough problem. Any help would be much appreciated. My alternative is to recode my OSCommerce image to not use arrays and I don't know how much these are used, so I obviously want to avoid that.

 

--Phil

Link to comment
Share on other sites

I found my answer. The problem only seems to happen with PHP 4.2.2 (and up probably). You have to use $_POST instead of $PHP_POST_VARS for array handling. The latter has always been the standard but something is broken in the implementation that I am using. I only had to change the portion of application_top.php that calls into the $cart->add_product(...)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...