It looks like you hand edited your recordset and added some php code. First you have opened up your recordset for SQL injection and shouldn't use code like you have to inject a variable into your SQL. Second, I believe that might be what is causing the repeat seleciton to fail since the Recordset isn't fully recognized.