I am having problems inserting data into a MYSQL database using the php code below:
$addStmt = "INSERT INTO $table(Name, Street, City, State, Zip, Agency_Contact, Phone, Fax, Date, DateTime) VALUES ('$POST[A_Name]', '$POST[A_Street]', '$POST[A_City]', '$POST[A_State]', '$POST[A_Zip]', '$POST[A_Agency_Contact]', '$Phone', '$Fax', '$Date', '$DateTime')";
//Execute the add statement
if(!mysql_query($addStmt, $link)){
error(sprintf("Error in executing %s stmt", $addStmt));
error(sprintf("error:%d %s", mysql_errno($link), mysql_error($link)));
$message = 0;
exit();
}
When i execute the page and code, I come up with this error message:
Error in executing Insert into Agency (Name, Street, City, State, Zip, Agency_Contact, Phone, Fax, Date, DateTime) VALUES ('lkjhlkjh', 'lkjhlkjh', 'lkjhlkjh', 'kj', 'lkjhl', 'lkjhkjlhlkjh', 'lkjlihlkjh', 'lkjlkjhlkj', '01/23/2003', '01:23:2003:13:07:47') stmterror:1136 Column count doesn't match value count at row 1
Now the only column i don't account for in the insert is the ID column as column number 1 because that is auto_increment. The interesting part is that when i go and check the database the information was actually entered eventhough php claims that it wasn't. I ran the sql code from the error message directly in mysql and it worked also. Again, the data was entered into the database. If anyone has any suggestions it would be greatly appreciated. Oh yes my table structure is as follows:
CREATE TABLE Participants (
ID int(8) NOT NULL auto_increment,
FirstName varchar(25) default NULL,
MiddleName varchar(25) default NULL,
LastName varchar(25) default NULL,
Suffix varchar(6) default NULL,
SSN varchar(9) default NULL,
Rank varchar(20) default NULL,
PromotionDate varchar(10) default NULL,
AgencyID varchar(4) default NULL,
DateTime varchar(20) NOT NULL default '',
UNIQUE KEY DateTime (DateTime),
UNIQUE KEY ID (ID)
) TYPE=MyISAM COMMENT='List of Enrolled Participants';
Thanks in advance