Reputation: 3
I've set id to AUTO_INCREMENT but code is not working. Can anyone help me with that? I've tried multiple things like NULL, DEFAULT, '' I'm using it in a php variable like
$x="INSERT INTO information (id, username)
VALUES ('', 'something')";
Help me in this. Thank You
INSERT INTO information (id, username)
VALUES ('', 'something');
Upvotes: 0
Views: 149
Reputation: 5359
Your INSERT statement is specifically attempting to set the ID column, so AUTO_INCREMENT won't work. Additionally, you're setting it to an empty string when the column requires an integer, so you're seeing the error message you posted.
To use an AUTO_INCREMENT column, omit it from your INSERTS:
INSERT INTO information (username) VALUES ('something');
Upvotes: 1