Member Avatar for James singizi

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

Post all your code relating to this using the 'code' link, then we can help.

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:

die($qry);

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.

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.