If it's become an obsesive thought and she has started missing school, then you may need more than just advice, you may need professional help with her.
A child psychiatrist would help her through by deconditioning and behavioural changes.
However, if that is not immediately possible, you may try the following:
First of all, do not be angry with her or tell her off when she freaks out. Accept this behaviour as normal for children her age. You can even tell her that, and tell her that she'll eventually grow out of it, as most of us have.
Try first taking her on short trips in a car or bus, then gradually lengthen the trip. The more she sees herself not needing to rush to the toilet, the more self confidence she'll gain.
Try also positive re-inforcement when she doesn't freak out. Buy her a chocolate or take her to the park, whatever she likes doing.
Dr. Heba Ismail, M.D.