The phrase walad al-zina refers to someone born outside marriage. Classical discussions sometimes reflect social assumptions, but no child bears blame for the circumstances of birth.
وَلَا تَزِرُ وَازِرَةٌ وِزْرَ أُخْرَى
Meaning: No bearer of burdens bears the burden of another.
The individual’s actual learning and conduct matter, and the stated prayer remains valid.