I prayed at a job without knowing the qiblah, so I faced a wall since I didn't know where the qiblah was. I could have done more to find it, since a mosque was five minutes away. I intend on repeating these prayers.
Later I pictured the mosque in my head and imagined where the qiblah was and prayed in that direction a number of prayers.
Later I found out that this was also wrong because I had imagined incorrectly, but I could have done more if I had used a compass or asked a Muslim coworker who also prayed... I found out that he prayed in a different direction but I wasn't sure he was right over me. Please advise me on what to do.
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Facing the Qiblah (i.e. the direction of the Ka‘bah in Makkah) is one of the conditions for the validity of prayer that must be fulfilled, and there is no room for personal reasoning to determine the direction of the Qiblah for someone who is in an urban area because he is able to know the correct Qiblah direction with certainty.
Ibn Qudaamah said in Al-Mughni: “As for a person who is able to see (not-blind), if he prays towards a direction other than the direction of the Ka‘bah in an urban area and then finds out that it was wrong, it is obligatory on him to repeat the prayer, whether or not he had asked someone about the Qiblah direction, because urban areas are not suitable for personal reasoning to determine the Qiblah. He can find the direction by looking at the niches in mosques and prayer areas, and he can usually find someone to inform him of the correct Qiblah direction with certainty. Therefore, he is not entitled to try to determine the Qiblah direction based on his personal reasoning, just like a person who has access to Sharee‘ah texts on religious rulings cannot opt for independent reasoning. So if he prayed without finding proof of the direction of the Qiblah and then found out that he prayed in the wrong direction, it is obligatory on him to repeat that prayer because of his negligence. If someone informs him of a direction and it turned out to be wrong, then he has misguided him and it becomes evident that his guidance is not proof.” [End of quote]
As long as you are in an urban area, then you are able to find out the correct direction of the Qiblah and ask someone to inform you of it. If you did not ask anyone and prayed towards a random direction, your prayer is not valid because of your negligence and failure to perform due diligence, and it is incumbent on you to repeat the prayer. Ibn Qudaamah said in Al-Mughni: “If he finds someone whom he can imitate or who can inform him of the correct Qiblah direction but fails to imitate him or ask him about it, or if he acted against the guidance of that person who informed him of the direction or the one who did due diligence to determine the direction and prayed anyway, his prayer is invalid in all these cases.” [End of quote]
Allah Knows best.
You can search for fatwa through many choices