Trying to insert POST data as new record in mysql database. Table has 5 columns:
ContractorID, firstName, lastName, email, password
$insert = "INSERT INTO CONTRACTOR (firstName, lastName, email, password)
VALUES ($firstName, $lastName, $email, $password)";
if (mysqli_query($conn, $insert)) {
echo "New record created successfully";
} else {
echo "Error: " . $insert . "<br>" . mysqli_error($conn);
}
ContractorID is an auto increment primary key and so I thought I could leave it off the insert. However, even when I change to:
$insert = "INSERT INTO CONTRACTOR (ContractorID, firstName, lastName, email, password)
VALUES ('DEFAULT', '$firstName', '$lastName', '$email', '$password')";
I get the same error:
Error: INSERT INTO CONTRACTOR (firstName, lastName, email, password) VALUES ('w4rwsfsdf', 'wqerwerw', 'rweqrqwer' 'qwerqwer') Column count doesn't match value count at row 1
EDIT: It was a missing comma causing the issue, I copied the code down wrong here and the error message correctly. Couldn't copy and paste linux to windows.