Some Bad Name
Some Bad Name

Reputation: 3

Auto Increment Not Working On MySQL & PHP. I've set th code properly but not working

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

Answers (1)

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

Related Questions