Shrike;10920607 wrote:The error refers to getData but the line you mention refers to getChild.
errr..sorry, when I copied the code, i had something like echo $peek->getData();...for testing purposes.
the strange part is..when I had that written down, it ECHOED what $peek->getData() was..and then gave the error after..
Get child is simply:
function getChild()
{
return $this->child;
}
here is the entire while loop with everything that may effect it (i will add a comment where the stack/peek business starts)
Thanks for looking at this!! hopfully its not too big of a problem >.<
$head = new nodeClass("head",null,null);
while($i < $num){
if(mysql_result($result,$i,"Part")!=null){
$newNode = new nodeClass("pa".$a,null,mysql_result($result,$i,"Part"));
$a++;
}elseif(mysql_result($result,$i,"Tier1")!=null){
$newNode = new nodeClass("t1".$b,"pa".$a,mysql_result($result,$i,"Tier1"));
$b++;
}elseif(mysql_result($result,$i,"Tier2") !=null){
$newNode = new nodeClass("t2".$c,"t1".$b,mysql_result($result,$i,"Tier2"));
$c++;
}elseif(mysql_result($result,$i,"Tier3") !=null){
$newNode = new nodeClass("t3".$d,"t2".$c,mysql_result($result,$i,"Tier3"));
$d++;
}elseif(mysql_result($result,$i,"Tier4") !=null){
$newNode = new nodeClass("t4".$e,"t3".$d,mysql_result($result,$i,"Tier4"));
$e++;
}
if($head->getNext() == null){
$head->setNext($newNode);
echo "1<br />";
}
elseif(($head != null)&&($newNode->getParent()==null)){
$probe = $head;
$check1=false;
while($check1 == false){
if($probe->getNext() == null){
$check1 = true;
}else{
$probe = $probe->getNext();
}
}
$probe->setNext($newNode);
/*Everything up to this elseif works fine (i commented just this else if, and it
worked 100% like it should) and then i fixed a few other problems...now the only
issue seems to be with my stack...granted there is probably another way to do
this if I cant figure it out, but This would be easiest...*/
}elseif($newNode->getParent() !=null){
$parent = $newNode->getParent();
$parentKey = $newNode->getKey();
$pointer = $head;
$parentFound = false;
$lastInColumn = false;
$stack = new Stack();
while($parentFound != true){
$pointerKey = $pointer->getKey();
if($pointerKey == $parentKey){//stopping condition
$parentFound = true;
$lastInColumn = false;
}else if($pointerKey != $parentKey){
if($pointer->getData() != null){
$stack->push($pointer);
}
if($pointer->getNext()->getData() != null){
$pointer = $pointer->getNext();
}else{
$lastInColumn = true;
}
}
if($lastInColumn == true){
$childCheck = false;
while($childCheck == false){
$peek = $stack->peek();
if($peek->getChild() != null){
$pointer = $peek->getChild();
$lastInColumn = false;
$childCheck = true;
}else{
$stack->pop();
}
}
}
}//end while
}
$i++;
}