in reply to Array ref error!

The empty string is in $sql, so likely, $sql does not hold your result set from your database query, which is somewhat natural.