I think etcshadow is on the right track. Your assignment from @data to $id, etc. looks fine to me, and dbnextrow() shouldn't return any references when called in this manner.
My guess is that a reference got inserted as a string - you can check this by using isql or some other basic query tool and run the same query to check the data in the database.