Column count does not match value count at row 1
Posted: Tue Jul 29, 2008 9:57 am
Yeah, I did Google it and found the supposed solutions but I still can't get this to work and I don't see where I have too many or too few fields as compared to the table in my database. For reference, I'm using the code from PHP Solutions: Dynamic Web Design Made Easy by David Powers. I've finally finished it and I'm now porting his code to my purpose... not well I might add
A SQL export of the donkeys table looks like this:
I know I know very little but I can't see my problem.
Thanks for any help...
Code: Select all
// connect to database as administrator
$conn = dbConnect('admin');
// check for duplicate username
$checkDuplicate = "SELECT donkey FROM donkeys WHERE email = '$email'";
$result = $conn->query($checkDuplicate) or die(mysqli_error($conn));
$numRows = $result->num_rows;
// if $numRows is positive, the username is already in use
if ($numRows) {
$message[] = "$email is already in use. Please choose another username.";
}
// otherwise, it's OK to insert the details into the database
else {
// add an encryption key
$key = 'key';
// insert details into database
$insert = "INSERT INTO donkeys (donkey, lastName, firstName, email, passWord, phone) VALUES ('', '$lastName', '$firstName', '$email', '$passWord', AES_ENCRYPT('$passWord', '$key'), '$phone')";
// execute the query
$result = $conn->query($insert) or die(mysqli_error($conn));
if ($result) {
$message[] = "Account created for $email.";
}
else {
$message[] = "There was a problem creating an account for $email.";
}
}
}Code: Select all
CREATE TABLE IF NOT EXISTS `donkeys` (
`donkey` int(3) unsigned NOT NULL auto_increment,
`lastName` varchar(24) NOT NULL,
`firstName` varchar(24) NOT NULL,
`email` varchar(36) NOT NULL,
`passWord` varchar(12) NOT NULL,
`phone` varchar(12) default NULL,
PRIMARY KEY (`donkey`),
UNIQUE KEY `email` (`email`),
KEY `lastName` (`lastName`,`firstName`,`email`)
)Thanks for any help...