peeing blood

At first I thought I was just starting my period and my pee was mixed with my blood but when I had went to pee again I made sure I wasn't bleeding before I peed and turns out I am having the feeling of a uti plus some blood.. I frequently have to pee as well but only a little comes out. IT HURTS! I did have safe sex twice in the last week, what does this mean?