This is a difficult question to answer. How do we reconcile the idea that our prayers influence God as James 5:16 implies, yet God knows all things as 1 John 3:20 says?
James 5:16, "Therefore, confess your sins to one another, and pray for one another, so that you may be healed. The effective prayer of a righteous man can accomplish much."
How is it possible for us to influence God who has always known all things from eternity? Does God interact with us in some sense of knowing what we will do and decides to do things in response? Or, does God decree whatsoever shall come to pass including our prayers, so that all our prayers are ultimately within his will? The debate within Christianity is deep. However, Scripture is clear. We know that God works "all things after the counsel of his will" (Ephesians 1:11). This means that he includes our prayers in the counsel of his will - from all eternity. But, does God look into the future to see what we are going to pray and then decide what to do based on that? This can't be, because it would violate the sovereignty of God who does not react to man's desires and offer "a backup plan" when he "changes his mind." Furthermore, looking into the future to see what would happen would imply that God was learning -- which contradicts 1 John 3:20 that says God knows all things. Furthermore, our prayers come from our hearts and the Bible tells us that God "moves the heart of the king where He wishes to go," (Proverbs 21:1).
On the other hand, James 5:16 says that our prayers can accomplish much. So, we have to ask how our requests to God can accomplish anything if God not only knows what we are going to pray, but has also ordained our prayers from the foundation of the world (Eph. 1:11)? The simple answer is that it is beyond our ability to comprehend. The Bible does not tell us how our interaction with God works, but it does tell us God hears our prayers when we pray according to his will (1 John 5:14). Such is the paradox in which we find ourselves.
Paradoxes occur only when there are absolutes. It is absolutely true that God knows all things and has ordained whatsoever shall come to pass (but this does not mean that he causes people to sin). It is also true that God desires that we pray. So how do our prayers influence God when he has ordained those very prayers to occur? Again, we don't know.
It would seem, however, that we "influence" God when we are in his will. In other words, if we are walking in the will of God and we ask God for something in prayer, then we are more likely to receive an answer because we are doing what he wants. In contrast, if we are out of the will of God and we ask him for something, he will not give it since it is not in his will. So, if we are walking in the will of God and we pray, we are praying according to his will and our prayers are answered in the affirmative. However, if we are not in his will, they're not answered in the affirmative. Therefore, the issue isn't if God answers our prayers, because he does. The issue is whether or not our prayers, and ourselves, are abiding in God's will so that our prayers will be answered.
We are the ones who need to have our wills changed according to his desires, not his will changed according to our prayers.