If you are looking for a free, open source, database driven, ad server then you should check out Revive. It is full of options, has lots of documentation and is relatively easy to setup and run. I am running it using the same domain as where my demo vLot website runs, stallonsusedcars2.com. I use it to serve various ads on my different websites and it works quite well.
Initially it took me about an hour to get it up and running and figure out the basics of using it. So if you want to rotate some ads using some php/MySql wizardry and have stats, ad-weighting, targeting and many other options, I suggest checking it out.
Follow Tim on Twitter @tl1000rzx2
Or check out my other blog: Tim's Incredibly Conservative Blog