I have the following code in which the recursive call to BaseFunc is failing. This is a function inside a class and if I comment out the recursive call, the code works fine. I've tried a number of methods of trying to get this to work and have had no success. My last resort will be removing the recursion completely.

function BaseFunc ($level, $prev) {
global $order, $AorD;
$sql ="select id, name from table WHERE parentid = '$prev' ORDER by $order $AorD";
$data = $this->select($sql);

// data is an array

if (!empty($data)) {
$limit=count($data);
for ($count=0; $count<$limit; $count++) {
$id=$data[$count][0];
$name=$data[$count][1];
print ("<tr><td><input name=\"parentid\" type=\"radio\" value=\"$id\">");
for ($x=0; $x<$level; $x++) {
print ("->");
} // for
print ("$name");
print ("</td></tr>");
this->BaseFunc($level+1,$id);
} //for $y<$z
} //if !empty($data)
else { print ("Empty2"); }
}

Any suggestions on why this recursive call would error out? The error message is always:
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /home/user/public_html/classfile.php on line 200

Line 200 is the line with the this->BaseFunc call.

    a year later

    Hello cleavela.

    I'm sure you've solved the problem by now, or at least the error. But if you're still working on this:

    Instead of:

    this->BaseFunc($level+1,$id);

    Try:

    $this->BaseFunc($level+1,$id);

    i.e. add "$" to "this->"

    HTH,

    --Noah

      Write a Reply...