in reply to Looping through MySQL

Using strict and warnings would have uncovered that the problem is your recursive calls to the function pushing values onto the global @info you return at the bottom.

Update: Oops.. upon further look, the problem is in $line = check_id($parent); which does not work as it looks because you are receiving an array. In scalar context, an array evaluates to the number of its elements, which is what $line then contains, and subsequently gets pushed onto the array. You wanted to say ($line) = check_id($parent); which forces list context and captures the first element of the list in the variable. However you will then get duplicate elements because your recursive calls, as I already said, are modifying the global @info.

Makeshifts last the longest.