I'm getting a "Variable Undefined" error, even tho phpinfo() shows me that
globals are set to ON.  I've done massive searches on the web to find a
solution, but I'm totally missing it.  Help?  (I've bolded where the
Variable Undefined is occuring --- where <<$whatglass =
$lkColor[$i]->glass;>> is written.)

Here's the code:

==============code start=========================
<? $whatx = $HTTP_GET_VARS['x'];
 if ($whatx != null ) {
  $whatx = $whatx;
   }else{
     $whatx = 0;
   }

error_reporting (E_ALL ^ E_WARNING); //Turn on all error reporting EXCEPT
warnings.

class dbColors
{
// var $code;
// var $name;
// var $glass;

 function dbColors($code,$name,$glass)
 {
  $numargs = func_num_args();
  //Array constructor function
  //Create a reference inside the global array $globalref
        global $globalref;
        $globalref[] = &$this;

  $this->code = $code;
  $this->name = $name;
  $this->glass = $glass;
 }
}

// $lkColor = array(dbColors($code,$name,$glass));
 $lkColor[0] = new dbColors;
 $lkColor[0]->dbColors("Z651","Red","9");

 $lkColor[1] = new dbColors;
 $lkColor[1]->dbColors("R3","Cranberry","8,9");
//rest are clipped

 define("test", count($lkColor));
// global test =  count($lkColor);

function ColorCollection($lkID){

 $whatX = $lkID + 1; // Adding 1 turns makes the index correspond to the
template number.

// $aColLen = count($lkColor); //.length
 $aColLen = test; //sizeof($lkColor); //.length

 echo "<option value=\"\" selected>xxx</option>\n"; //first option is blank

// KeepGoing: //PHP does not have a line-label statement.  Set up a trigger
 for($i=0;$i<$aColLen;$i++){
      $trigger = false;
      $whatglass = $lkColor[$i]->glass; //shouldn't $lkColor[any-number] be
global??? <<<<<<<<<<<
      // collect/build the option

      //if $lkID = egg or ornament (template numbers 8 or 9)
      if($whatX == 8 || $whatX == 9){ // if yes to either
           if($whatX == 8){
            $pos = strpos($whatglass,"8");
                if($pos === true){
                 echo "<option
value=\"{$lkColor[$i]->code}\">{$lkColor[$i]->name}</option>\n";
                 //continue KeepGoing;
                 $trigger=true;
                 continue;
            }
    }
   if($whatX == 9){
        $pos = strpos($whatglass,"9");
            if($pos === true){
                 echo "<option value=\"" . $lkColor[$i]->code . "\">" .
$lkColor[$i]->name . "</option>\n";
                 //continue KeepGoing;
                 $trigger=true;
                 continue;
            }
       }
  }else{
       if($trigger == false){
            echo "<option value=\"" . $lkColor[$i]->code . "\">" .
$lkColor[$i]->name . "</option>\n";
            continue;
       }
    } //EndIf either 8 or 9
  } // FOR colors loop
} // end function
?>

==============code end==========================

I'm calling the function this way:

    <select name="Main_color" id="Main_color" size="1"
onChange="ChangeColor(this.id)" style="width:80pt;">
       <?  ColorCollection($whatx); ?>
    </select>


How can $lkColor[$i]->glass not be global?

-ron
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to