fixed upload problems + sql queries

still need 2 do some other things