Unknown column '$i' in 'where clause'