PDA

View Full Version : Unknown column 'XXXX' in 'field list'


yebirtiebal
10-21-2007, 12:51 PM
Hi,
I working in my project which I am using Java with mysql. While I am running my program I got the error.
Unknown column 'XXXX' in 'field list'
where xxxx is attribute value.
Here is the fragment of code where the error occures. Please help me.


String fn, ln, phone, address;
System.out.println("Enter Customer Detail...");
System.out.println("========================");

//System.out.println("Enter Customer ID...");
//cID=in.nextInt();
System.out.println("Enter Customer First Name...");
fn=in.next();
System.out.println("Enter Customer Last Name...");
ln=in.next();
System.out.println("Enter Customer phone...");
phone=in.next();
System.out.println("Enter Customer address...");
address=in.next();


//write to customer table
String s1="insert into customer( FName, LName, phone, address) values("+fn+", "+ln+", "+phone+", "+address+")";

shyam
10-21-2007, 01:39 PM
Unknown column 'XXXX' in 'field list'
String s1="insert into customer( FName, LName, phone, address) values("+fn+", "+ln+", "+phone+", "+address+")";

are the column names the same in the actual table?

yebirtiebal
10-22-2007, 06:14 AM
Yes they are the same except i have one column at the beginning. Since this coulmn is created to increment automatically it doesn't need to be included here.

yebirtiebal
10-22-2007, 07:57 AM
Thank you very much. Now I am able to fix the problem as follows:
String s1="insert into customer(FName, LName, phone, address)"
+" values ('"+fn+"','"+ln+"','"+phone+"','"+address+"')";

esubalew a.