check correct variable for SQL error