UTI while Pregnant?!

Daisy
I went in to the ER today about my pelvic pain on my right side, and they cleared me of an ectopic pregnancy. I'm 4 weeks along & the doctor said I have UTI , she gave me antibiotics... But she also said that a UTI can cause a miscarriage. I'm scared. Has anyone been through this before?