in reply to retrieve data from array empty
The code you posted ...
You should repair those problems first.
Alexander