How to fix it? Eat. Good, substantial meals and snacks consistently throughout the day, every day. Your body cannot function properly if you are depriving it of the nutrients and energy it needs. Please eat some food, now.
It would also be a good idea to contact a GP who can help sort out some support for you, as it seems that your mindset is dangerously skewed (it is really not healthy at all to be blacking out and fainting etc.), and could result in some (even more) serious consequences to your health and life.