Camera spherical coordinates

I am trying to have my camera move in a given azimuth and elevation.

I have used the following formulas which have not worked for me.
Any suggestions?

posx = posx + cos(azimuth)*sin(elevation);
posy = posy + sin(azimuth)*sin(elevation);
posz = posz - cos(elevation);

I have modified to use

posx = posx + cos(elevation)*sin(azimuth);
posy = posy + sin(elevation)*cos(azimuth);
posz = posz - cos(elevation);

This seems to work but when the azimuth gets too high or low, say above 90, the camera starts turning the opposite direction.

It’s called gimble lock. Search the boards or google it for details and solutions.