I am getting the error “Column count doesn’t match value count at row 1” and don’t know why. I know it sounds like my php script has too few or too many results for my database but I’m not sure. I have tripple checked everything so don’t know how to fix. Please help. in my database the first entries will go in which are f_name and l_name with $add_master but then the address section will not enter in the database. Below is my script and is lengthy so I will color the part that I believe to be the issue but unsure how to fix:
<?php
if ($_POST[op] != "add") {
$display_block = "
Add an Entry
First/Last Names:
Address
City/State/Zip:
Address Type
home
work
other
Telephone Number
home
work
other
Fax Number
home
work
other
Email Address
home
work
other
Personal Note:
";
} else if ($_POST[op] == "add") {
if (($_POST[f_name] == "") || ($_POST[l_name] == "")) {
header("Location: addentry.php");
exit;
}
$conn = mysql_connect("localhost", "xxxx", "xxxx")
or die(mysql_error());
mysql_select_db("xxxxxxx",$conn) or die(mysql_error());
$add_master = "insert into master_name values ('', now(), now(),
'$_POST[f_name]', '$_POST[l_name]')";
mysql_query($add_master) or die(mysql_error());
$master_id = mysql_insert_id();
if (($_POST[address]) || ($_POST[city]) || ($_POST[state]) ||
($_POST[zipcode])) {
$add_address = "insert into address values ('', $master_id,
now(), now(), '$_POST[address]', '$_POST[city]',
'$_POST[state]', '$_POST[zipcode]' '$_POST[add_type]')";
mysql_query($add_address) or die(mysql_error());
}
if ($_POST[tel_number]) {
$add_tel = "insert into master_telephone values ('', $master_id,
now(), now(), '$_POST[tel_number]', '$_POST[tel_type]')";
mysql_query($add_tel) or die(mysql_error());
}
if ($_POST[fax_number]) {
$add_fax = "insert into fax values ('', $master_id, now(),
now(), '$_POST[fax_number]', '$_POST[fax_type]')";
mysql_query($add_fax) or die(mysql_error());
}
if ($_POST[email]) {
$add_email = "insert into master_email values ('', $master_id,
now(), now(), '$_POST[email]', '$_POST[email_type]')";
mysql_query($add_email) or die(mysql_error());
}
if ($_POST[note]) {
$add_note = "insert into personal_note values ('', $master_id,
now(), now(), '$_POST[note]')";
mysql_query($add_note) or die(mysql_error());
}
$display_block = "Entry Added
Your entry has been added. Would you like to
add another?
";
}
?>
Add an Entry
<? print $display_block; ?>