Flesh – has to do with the body. Heart – has to do with the INNER PERSON, Mind, will, emotional. “FAILS” – means to be DEPLETED, to be exhausted of Resources, run out, DEPLETED OF resources to handle problems and life. “My flesh and my heart may fail, BUT GOD is the strength of my heart and my portion forever.” The word “Strength,” in Hebrew is “rock;” the rock on which my heart relies; that is, my refuge, my defense…the Rock upon which he can rest on, rely upon! God is a sure foundation to build upon and rest on! Though his flesh fails…his faith Flourishes! A little like Abraham who considered his own body and that of Sara’s and realized it was impossible to have a child as they were so old, but he believed God and what He promised He would deliver on, and he “did not waver in unbelief but grew in faith giving glory to God.” -{Read Rom 4:20-21}. He did not end with himself, though he acknowledged his condition but he ended with GOD! It is not to deny what is happening but it is not to end there for that will only lead to despair, But Look To Him! These two wonderful words throw open the door of faith, “BUT GOD… ”  “…is the strength of my heart and my portion forever.” 
The Psalmist realized where he ran out, gave out, God poured in. God was his Strength, his Rock, and his Portion and that…forever! There was a “BUT GOD…” for him as there is for you too in your predicament. His Presence is your goodness. The Lord is near, it is not a matter of feeling but of fact!-{Read HEB 13:5}. He was also his  Refuge!
“But as for me, the nearness of God is my good; I have made the Lord GOD my refuge, That I may tell of all Your works.” –
His PRESENCE  = my  Goodness – 🙂
HIS PROTECTION = my Refuge – 🙂
HIS PROCLAMATION =  His mission, delight, was to Tell of God’s Works!-🙂

Enjoy Him. Praise Him. Tell of Him, His Goodness, and His Works!