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

**URL:** https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539
**Category:** programming
**Created:** [July 23, 2004, 9:55am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539 "2004-07-23T09:55:20Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Phat7](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Phat7](https://forum.kirupa.com/u/Phat7)
#### Post date: [July 23, 2004, 9:55am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/1 "2004-07-23T09:55:20Z")

</div>

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](http://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.

```php
// 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:

```php
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:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 11:06am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/2 "2004-07-23T11:06:39Z")

</div>

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

And make a status…

```php
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… 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 11:47am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/3 "2004-07-23T11:47:30Z")

</div>

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:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:30pm UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/4 "2004-07-23T20:30:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 11:38pm UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/5 "2004-07-23T23:38:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 7:08am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/6 "2004-07-24T07:08:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 12:38pm UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/7 "2004-07-24T12:38:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 5:25pm UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/8 "2004-07-24T17:25:48Z")

</div>

So … what was the problem?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 25, 2004, 11:46am UTC](https://forum.kirupa.com/t/calling-all-php-mysql-gurus-neither-result-nor-error/58539/9 "2004-07-25T11:46:03Z")

</div>

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:
