Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Quote/apostrophe in an array


Recommended Posts

Hi all,


I've installed the Product Attributes - Option Type feature contribution (http://www.oscommerce.com/community/contributions,160/) and for the most part it's working fine. This contrib allows you to have text based options for products, so customers can for example enter text they'd like printed on a product in the store.


My problem is that if the user enters text that contains an apostrophe, then chooses to update the quantity in the shopping cart, all options for that product are lost. If the text options don't contain an apostrophe, the contrib works perfectly.


I have compared my files with the contrib so many times, and have also compared with someone else whose site is working perfectly with this contrib - I can see no material differences in the code.


The only diff I can see is that I'm on a server running PHP5 and he's on a server running PHP4 - could this have something to do with the problem?


I think that I need to do something with stripslashes or addslashes or htmlspecialchars or some such but I don't know where or what to change.


When the item is added via product_info.php it goes into the cart fine - complete with the tex option containing a quote - but the problem only arises when I hit the 'update' button, so I'm thinking the problem is in includes/classes/shopping_cart.php - in the update_quantity function.


Also, don't know if this is relevant, but my $attributes is failing an is_array check - presumably because of the apostrophe - where and how can I ensure that the $attributes array is properly formed such that a customer can enter an apostrophe if they want?


Many thanks in advance,



p.s. if anyone can help simply by confirming that they have this contrib running on PHP5 - with a positive result from the test described above, that would help too!

Link to comment
Share on other sites

Further to my post aove, I'm thinking that this line from product_info.php is crucial:


$tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$_GET['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'"> ' . $products_options_name['products_options_comment'] ;



This line builds part of the form that allows customers to add their personalisation text.



My question is this: how can I amend that line to ensure that PHP5 will see the $_GET array as an array if one of the text option conains an apostrophe?


All my problems with disappearing options seem to revolve around the fact that I'm failing is_array if statements that I ought to be going into....so (I think) I need to ensure that the form input field above is somehow 'corrected' if it contains a quote/apostrophe. If this is possible, it's beyond my PHP skills - any advice i very very gratefuly received.





p.s. in case it's relevant magic_quotes have been checked and are off.

Link to comment
Share on other sites


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

  • Create New...