Guest Posted March 8, 2004 Posted March 8, 2004 (edited) Hi all I installed the option type feature v1.4 for MS1 ages ago and the option for text works fine. However, I now have the need to have a normal dropdown option list and it doesn't work!!! I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/julie/public_html/wholesale/includes/functions/database.php on line 99 Can be seen here: http://cheapsheetmusic.co.uk/wholesale/pro...roducts_id/1694 Thing is, I didn't change anything in database.php so the problem must actually lie in product_info.php It's kind of a mess in there as I have attributes sorter and copier along with option type feature, so maybe I missed something out. This is the section of code from product_info.php which calls the attributes: <?php ? ?$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); ? ?$products_attributes = tep_db_fetch_array($products_attributes_query); ? ?if ($products_attributes['total'] > 0) { ? ? ?$products_options_name = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'" . " order by popt.products_options_sort_order"); ? ? ?echo '<b>' . TEXT_PRODUCT_OPTIONS . '</b><br>' . ? ? ? ? ? '<table border="0" cellpadding="0" cellspacing"0">'; ? ? ?// dogu 2003-02-28 update query to pull option_type ? ? ?// clr 2003-03-15 add order by statement to query ? ? ?$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' order by popt.products_options_id"); ? ? ?$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { //dogu 2003-02-28 BEGIN Add if statement to check product option type. If add more option types, then change this to a case statement. if ($products_options_name['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT) { // dogu 2003-02-28 add query to pull attribute price and price_prefix $products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'"); $products_attribs_array = tep_db_fetch_array($products_attribs_query); echo '<tr><td class="main">' . $products_options_name['products_options_name'] . ': </td><td class="main"><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[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'"> ' . $products_options_name['products_options_comment']; if ($products_attribs_array['options_values_price'] != '0') { echo '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], $product_info_values['products_tax_class_id']) .') '; } echo '</td></tr>'; } else { ? ?//dogu 2003-02-28 END Add if statement to check product option type. ? ? ? ?$selected = 0; ? ? ? ?$products_options_array = array(); ? ? ? ?echo '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n"; // BOF: WebMakers.com Added: Attributes Copy and Sort ?if ( PRODUCTS_OPTIONS_SORT_BY_PRICE !='1' ) { ? ? ? ?$products_options = tep_db_query("select pa.products_options_sort_order, pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'" . " order by pa.products_options_sort_order, pov.products_options_values_name"); ?} else { ? ? ? ?$products_options = tep_db_query("select pa.products_options_sort_order, pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'" . " order by pa.products_options_sort_order, pa.options_values_price"); ?} // EOF: WebMakers.com Added: Attributes Copy and Sort ? ? ? ?while ($products_options = tep_db_fetch_array($products_options_query)) { ? ? ? ? ?$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); ? ? ? ? ?if ($products_options['options_values_price'] != '0') { ? ? ? ? ? ?$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; ? ? ? ? ?} ? ? ? ?} ? ? ? ?echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); ? ? ? ?echo '</td></tr>'; // dogu 2003-02-28 insert closing bracket due to if statement ? ? ?} ? ? ?} ? ? ?echo '</table>'; ? ?} // EOF: attribute options /////////////////////////////////////////////////////////////////////////// ?> This is the appropriate section of database.php: function tep_db_fetch_array($db_query) { ? ?return mysql_fetch_array($db_query, MYSQL_ASSOC); ?} PLEASE can anyone help!! I probably did something wrong when merging the files, missed something out or duplicated something. Edited March 8, 2004 by JulieCSM Quote
Guest Posted March 8, 2004 Posted March 8, 2004 BUGGER!!! I just checked my products with text options and they're all messed up now also!! Showing the same error. They were fine before! Help!! Quote
Guest Posted March 24, 2004 Posted March 24, 2004 Hi Julie Did you manage to fix this problem? I have just installed Option Type and have encountered exactly the same problem, so if you have now fixed it I'd be grateful to know how! Thanks John Quote
Guest Posted March 24, 2004 Posted March 24, 2004 I didn't. I just changed my system so there were no dropdown lists. Once I deleted the extra options I had put in for the drop down lists, the type options went back to normal. Annoying but I couldn't see any other way to fix it, and it was urgent. Quote
♥ecartz Posted March 25, 2004 Posted March 25, 2004 $products_options = tep_db_query should be $products_options_query = tep_db_query in both places where it appears, so that it can be referenced in while ($products_options = tep_db_fetch_array($products_options_query)) { Hth, Matt Quote Always back up before making changes.
Guest Posted March 25, 2004 Posted March 25, 2004 Thank you very much! I have changed it and, while I haven't tested it yet with any new options, it certainly hasn't messed any existing ones up, which is all good! Happy now! :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.