Unable to prepare MySQL statement (check your syntax) - Unknown column 'g' in 'where clause'