PHP MYSQL列数不匹配[关闭]

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.

As per your originally posted question before you added the missing comma and not marking it as an "edit".

You have a comma missing in your VALUES

VALUES ('DEFAULT' '$firstName'
                 ^ right there

change it to:

VALUES ('DEFAULT', '$firstName'

Edit:

I suggest you delete/drop your present table if you can, and run the following:

$sql = "CREATE TABLE IF NOT EXISTS CONTRACTOR
(
  `ContractorID` int(10) NOT NULL AUTO_INCREMENT,
  `firstName` varchar(55) DEFAULT NULL,
  `lastName` varchar(55) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`ContractorID`)

            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

INSERT INTO CONTRACTOR (firstName, lastName, email, password)
VALUES ('John', 'Doe', 'email@example.com', 'test_password')";

if (mysqli_query($conn, $sql)) {
    echo "New table created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

Then try the query again.

$insert = "INSERT INTO CONTRACTOR (firstName, lastName, email, password)
VALUES ('Bob', 'Smith', 'email_2@example.com', 'test_password_2')";

if (mysqli_query($conn, $insert)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $insert . "<br>" . mysqli_error($conn);
}