When I prayed the two Fard prayers of Fajr, my neck has been suffering for a while, also when I prayed Zuhr or Asr, and also during the one last rakats of Maghrib and the two last rakats for Isha.
I was wondering whether my prayer is still valid.
If by ruin you mean you missed prayer then yes it is sin and you should offer missed prayers. But if your mean you offered prayers but they were not looking perfect due to pain or illness then your prayers are offered if you offered to the level best you was capable. In prayer leverage is given on medical basis, you have to offer in any situation to the level best possible. In worst case you can offer prayers with signs and they are accepted by Allah.