You must know the chord progression, which your soloing over. That way you can pick the correct scale to play over it. Most solo's sound lame cause they're using the same scale thoughout the solo, you have to mix it up to make it sound more interesting. Giving it a sense of flow, and movement rather than being stagnate.
A good way to learn how this all works is learn a song you like with a solo in it. Learn both the rhythm and the solo, then figure out how they come together. Take alittle Music Theory so you can understand how it works, there's also alot of threads and tricks on here just use the search to find them. You will find alot of pointers.
"My whole life is a dark room...ONE BIG DARK ROOM" - a.f.i.