fixed php problems and finished sql string