Okay First off i cant figure out where my code is wrong

i have stored the ID of the records i want to delete to an array called
todelete[] these values are taken from checkbox called delete (stored the ID of the record to the value parameter of the checkbox)

i want to delete thesed from the database here is the code i have so far

String todelete[] = request.getParameterValues("delete");




for (int i = 0; i < todelete.length; i++)
{

String sqld = "DELETE FROM table_name WHERE id='"+todelete[i]+"'";
// heres where an error pops up i just want to know to pass in the values of the array

    
}

any help would be appreciated


The error i am getting is as follows

org.apache.jasper.JasperException: An exception occurred processing JSP page /file.jsp at line 248

245:
246:
247:
248: for (int i = 0; i < todelete.length; i++)

osirion666,

......
  String todelete[] = request.getParameterValues("delete");
  if(todelete!=null) {
       for (int i = 0; i < todelete.length; i++) {
             String sqld = "DELETE FROM table_name WHERE 
                                 id='"+todelete[i]+"'";
        }
  }
....
commented: Thanks +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.