The first column in a MySQL table of mine is the primary key with auto increment. I am trying to add a new row with PHP like this.
mysql_query("INSERT INTO users VALUES ('', '$username', '$hashedPassword')");
What should I put in '' or the first field? It is auto generated, but I don’t want the field to be empty.
Interestingly, making the field empty works, but I am afraid if this breaks in certain circumstances I have not encountered. What is the standard entity to put there?
Also, does your solution also apply to timestamp fields that default to the current time?
I am new to PHP and MySQL. Thanks.
It’s good to get into the habit of specifying your fields like this
Or if you want to specify the id field too use NULL
By specifying the fields, your code is less likely to break if, for example, you add an extra field to the table.