Thanks for sharing your concerns.
The boy is suffering from constipation
which is quite common with change of formula or introduction of solids at this age.
The blood beside the back passage is due to "anal fissure", a tiny bit of tear in the inner lining of anus caused by hard poo.
This anal tear is painful & generally takes 4-6 weeks to heal and till that healing takes place ask your doctor to prescribe stool softeners .
Local application of cream is also helpful in relieving pain.
Also review his diet with the doctor & consider increasing water intake.
Hope you find the information useful.
Wishing him a speedy recovery.