im trying to submit data from my form into a database. After validating everything the code to insert the data is:
$qry = "insert into users(id, name, surname,email, password,date) values (id,'$name','$surname','$email','$password','$date')";
On testing the code i get an error that says:"error: unkown column 'geek' in field list".
geek corresponds to the password i entered in the form. The id value is an auto increament. Pliz help me out

5 Years
Discussion Span
Last Post by broj1

An issue I see that may be related:

values (id,'$name','$surname','$email','$password','$date')";

If your ID is auto-populated via AUTO_INCREMENT, you shouldn't be including it in your INSERT statement:

$qry = "insert into users(name, surname,email, password,date) values ('$name','$surname','$email','$password','$date')";

Alternatively, if you're manually assigning IDs, then id in the quoted text should be '$id':

values ('$id','$name','$surname','$email','$password','$date')";

Quote the field names with backtick (assumming that you use mysql):

$qry = "insert into users (`name`, `surname`, `email`, `password`, `date`) 
values ('$name', '$surname', '$email', '$password', '$date')";

This is how you make sure column names do not clash with any keywords. Not sure if this is the right solution for your problem, though.

You can also check the query by adding this line:


It will display the query and stop the script. Now you can paste the query into phpmyadmin and test it. You can also post it here for us to see.

Edited by broj1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.