[PHP] Variable Undefined, even when global?

2003-03-08 Thread Ron Biggs
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=
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 "xxx\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 "code}\">{$lkColor[$i]->name}\n";
 //continue KeepGoing;
 $trigger=true;
 continue;
}
}
   if($whatX == 9){
$pos = strpos($whatglass,"9");
if($pos === true){
 echo "code . "\">" .
$lkColor[$i]->name . "\n";
 //continue KeepGoing;
 $trigger=true;
 continue;
}
   }
  }else{
   if($trigger == false){
echo "code . "\">" .
$lkColor[$i]->name . "\n";
continue;
   }
} //EndIf either 8 or 9
  } // FOR colors loop
} // end function
?>

==code end==

I'm calling the function this way:


   



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



Re: [PHP] Variable Undefined, even when global?

2003-03-08 Thread Ron Biggs
You are a god among men, Ernest. THANK YOU!

-ron

"Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> At 01:28 09.03.2003, Ron Biggs said:
> [snip]
> >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 "xxx\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??? <<<<<<<<<<<
> [snip]
>
> Yes it _is_ global, but within the function you need to declare if global
> to have access to it, if you miss this you're referencing a local
variable,
> which is not defined...
>
> function ColorCollection($lkID){
>
>  global $lkColor; //
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>  $whatX = $lkID + 1; // Adding 1 turns makes the index correspond to the
> template number.
> // $aColLen = count($lkColor); //.length
>  $aColLen = test; //sizeof($lkColor); //.length
>  echo "xxx\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???
>
>
>
> --
>>O Ernest E. Vogelsinger
>(\)ICQ #13394035
> ^ http://www.vogelsinger.at/
>
>



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