Passing data to a MySQL database
Hi I'm having a little trouble passing a few variablesin to a database using a java servlet, here is the code I am working with and what I have attempted so far...
Code :
String ID = request.getParameter("ID");
String name = request.getParameter("name");
String surname = request.getParameter("surname");
String degree = request.getParameter("degree");
String DOB = request.getParameter("DOB");
These are my variables which pulled form another HTML form
I want to pass these into a table 'students' which is already created.
the trouble I am having is concatenating the statement so it will work through Mysql, I am sure it is very simple but I just can't figure it out.
This is what I have tried so far
Code :
String updateSQL = "insert into students (studentno, firstname, surname, degreecode, dob) values '" + ID + "',"+"'" + name + ",'"+"'" + surname + ",'"+"'" + degree + ",'"+"'" + DOB + "'}";
Thanks in advance for any help!
Re: Passing data to a MySQL database
Nevermind, sorted it out ;)
this is the code if anyone is interested...
Code :
String updateSQL = "insert into students (studentno, firstname, surname, degreecode, dob) values ('" + ID + "',"+"'" + name + "',"+"'" + surname + "', "+"'" + degree + "' ,"+"'" + DOB + "')";