Calling all PHP/MySQL Gurus: Neither result nor error!

I posted this on other forums and of course didn’t get any help :sure: So I’m returning to my home Kirupaforum. This is going to be a little long. I’ll try to make it as short and clear as possible.

First if you go to www.dvdtaxi.net and click on a dvd and look at the information page, you’ll see a small drop-down list below with options to rent or purchase. These prices are for guests. If you login, you will get a different rent and purchase price. Basically there are 6 options:

1 Rent
2 Rent Basic
3 Rent Premium
4 Purchase
5 Purchase Basic
6 Purchase Premium

1 and 4 are for guests and default members
2 and 5 are for Basic members which pay a membership fee
3 and 6 are for Premium members which also pay a fee

Now my problem is that I have modified the code to show two of the six options above depending on the type of client. But it only works for guests. If someone logs in, the options disappear.

Here is the code I use. Don’t pay attention to the “tep_” functions, they are standard osc functions.

// customer type
	if (tep_session_is_registered('customer_id')) {
	$customertypesall = tep_db_query("select customers_groups_id from customers where customers_id = '" . (int)$customer_id . "'");
	$customertype = tep_db_fetch_array($customertypesall);	
	if ($customertype["customers_groups_id"] == 3) {
	$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 = '" . (int)$languages_id . "' order by popt.products_options_name");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $products_options_array = array();
        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and (pov.products_options_values_id = '3' or pov.products_options_values_id = '6')");
        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($product_info['products_id'], $products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
          }
        }

        if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
          $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
        } else {
          $selected_attribute = false;
        }
		}
		} elseif ($customertype['customers_groups_id'] == 2) {
	$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 = '" . (int)$languages_id . "' order by popt.products_options_name");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $products_options_array = array();
        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and (pov.products_options_values_id = '2' or pov.products_options_values_id = '5')");
        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($product_info['products_id'], $products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
          }
        }

        if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
          $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
        } else {
          $selected_attribute = false;
        }
		}
		}
		} else {
	$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 = '" . (int)$languages_id . "' order by popt.products_options_name");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $products_options_array = array();
        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and (pov.products_options_values_id = '1' or pov.products_options_values_id = '4')");
        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($product_info['products_id'], $products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
          }
        }

        if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
          $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
        } else {
          $selected_attribute = false;
        }
		}

First I thought the problem was in the very beginning where I identify if the session is registered and then try to fetch the customer group id according to the session id. But I have also put a small code at the end of the page like this:

if (tep_session_is_registered('customer_id')) {
	$customertypesall = tep_db_query("select customers_groups_id from customers where customers_id = '" . (int)$customer_id . "'");
	$customertype = tep_db_fetch_array($customertypesall);
	if ($customertype["customers_groups_id"] == 3) {
	echo ('<b>You are a premium member</b><br>');
	} elseif ($customertype["customers_groups_id"] == 2) {
	echo ('<b>You are a basic member</b><br>');
	}
	} else {
	echo ('If you are a member please log in to see your special privileges. If you are just a registered user please log in to see the latest prices');
	}

and this code works perfectly!

If anyone could and wants to help me :ne: I would be thankful forever… :love:

I’m lost :crying:

if some one logs in you should make a SESSION…
$status = $_GET[‘status’];
sessionstart($status);

And make a status…

if($_SESSION['status'] == "Basic_Member"){
print('2 and 5');
} 
if ($_SESSION['status'] == "preminem_Member"){
print ('3-6');
}
if ($_SESSION['status'] == ""){ 
// session empty wich would mean guest.
print ('1 and 4')
}

That’s how I would do it… :stuck_out_tongue:

T-O, my dear friend, the sessions are already there. This **** OsCommerce has a whole bunch of functions on sessions. See that “tep_session_is_registered” function up there? That checks if the session is registered, and if it is, the next few f***in lines are supposed to find out what type of client has logged on… :sigh:

Anyway, thanks for helping though, any other ideas?.. :tb:

Maby you should get somebody to do the job for you, since it being so Ecommerce :slight_smile:

I’m sorry I can’t be more help, but I’ve had a lot of “fun” experiences with osCommerce in the past…

My solution, if you want to call it that, is put some debug ‘print’ statements in there, and find out which code path you’re travelling in each case.

The thing is that I’m sure it’s some syntax error and I can’t find it. I’ve tested every way possible. Gonna try the ‘print’ way I guess.

Fixed it!!! I fixed it!!! OMG, I’m so happy!!! :bounce: :angel: :trout: :love: (-: :crazy: :tie: :thumb: :pleased:

So … what was the problem?

In simple terms, the function which creates the pulldown menu based on the info from the database was getting the variables twice, the second time variables not satisfying the if statement.

Anyway, I inaugurate myself as the master of OsCommerce :trout: